model - Laravel Getting Child table values with multiple Parent values -


i need find solution in laravel 5. let me explain problem have 4 tables lets suppose these users, table1, table2, table3.

users , table1 have many many relationship. table1 , table2 have many many relationship. , table2 , table3 have many many relationship.

now on table3 controller want values respect user. example

   $table1 = user::find(auth::user()->id)->table1()->get()->lists('id');    $table2 = table1::wherein('id',$table1)->table2()->get()->list('id');    $table3 = table2::wherein('id',$table2)->table3()->get(); 

on table2 data getting error of badmethodexception. have googled , read documentation unable anywhere.

can me how can data please?

i have pivot table of table1_user, table1_table2 , table2_table3.

in user model have function

public function table1(){    $this->blongstomany('app\table1'); } 

in table1 model have function

public function table2(){    $this->belongstomany('app\table2'); } 

in table2 model have function

public function table3(){    $this->belongstomany('app\table3'); } 

i hope make sense.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -