laravel - Why does Eloquent change relationship names on toArray call? -



laravel - Why does Eloquent change relationship names on toArray call? -

i'm encountering annoying problem laravel , i'm hoping knows way override it...

this scheme allows sales reps see inventory in territories. i'm building editor allow our sales manager go in , update store acl can manage reps.

i have 2 related models:

class store extends eloquent { public function storeaclentries() { homecoming $this->hasmany("storeaclentry", "store_id"); } } class storeaclentry extends eloquent { public function store() { homecoming $this->belongsto("store"); } }

the thought here store can have many entries in acl table.

the problem this: built page interacts server via ajax. manager can search in variety of different ways , see stores , current restrictions each acl. controller performs search , returns info (via ajax) this:

$stores = store::where("searchcondition", "=", "whatever") ->with("storeaclentries") ->get(); homecoming response::json(array('stores' => $stores->toarray()));

the response client receives looks this:

{ id: "some id value", store_ac_lentries: [ created_at: "2014-10-14 08:13:20" field: "salesrep" id: "1" store_id: "5152-usa" updated_at: "2014-10-14 08:13:20" value: "salesrep id value" ] }

the problem way storeaclentries name mutilated: becomes store_ac_lentries. i've done little digging , discovered it's toarray method that's inserting funky underscores.

so have 2 questions: "why?" , "how stop doing that?"

it has in mutual automatic changing camelcase snake_case. should seek alter function name storeaclentries storeaclentries (lowercase) remove effect.

laravel laravel-4 eloquent

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -