laravel - Get foreign key column with a pivot table in between the first two arguments of a user I.E. Auth::user()->account->job -


ok have been googling lot , found nothing. how take auth::user() object accounts user pivot sub item jobs. so.

//gets me user object $user = auth::user(); //pivot table  account_user //gets me users accounts $accounts = $user->account()->get(); //this gets me accounts correct jobs $accounts =  account::with('job')->get();  class account extends model{     public function user() {return $this->belongstomany('app\user')->withpivot('a','b','c','d')->withtimestamps();}      public function job(){return $this->belongsto('app\job');} } class user extends model implements authenticatablecontract,authorizablecontract,canresetpasswordcontract{  public function account(){return $this->belongstomany('app\account')->withpivot('a','b','c','d')->withtimestamps(); } 

so wanting accounts user has , on each of them want job_id have replaced foreign column name or able json object makes.

to need use on accounts model so. $accounts = $user->account()->with('financialinstitution')->get();


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -