Wednesday, May 16, 2018

Laravel relationship across multiple tables fails - development

Laravel relationship across multiple tables fails

I have the following tabels

table check

 id
 name ...

table setting type

id
name
level //references id on table check

tabel settings

type, //references type on table setting type
name
value

So basically i would like to return all checks with settings

So i have in my models

1.Check model // references table check

    public function settingsval(){
       return $this->hasMany('AppAppSettingTypes','name','name.setting');
   }

On my AppSettingTypes // references table setting type

    public function settings(){
       return $this->hasMany('AppAppSetting','id','type');
   }

SO on my controller am simply doing

CheckModel::with('settingsval')

But everytime the settings array is empty even though there is data

What could be wrong?



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-relationship-across-multiple-tables-fails/
via Lzo Media

No comments:

Post a Comment