I have a tables:
categories - this is vehicle categories
dicts_groups - i have a lot of things there
dicts - for my dict groups i see what is body type(s)
category_dict_group - pivot table
My category class
public function bodyTypes()
{
return $this->belongsToMany('App\DictGroup');
}
this is my dictGroup class
public function dicts() {
return $this->belongsTo('App\Dict');
}
I want get all body parts for category = 1 so my code is simple now:
dd(Category::find(1)->bodyTypes()->pluck('id'));
result is
Collection {#248 ▼
#items: array:1 [▼
0 => 7
]
}
which is ok cause 7 is my dict_group_id from pivot table i think. How can i get body type list from dict ? like what i need add to function bodyTypes to get list like from table DICTS (id, symbol, public_name)
via Chebli Mohamed




Aucun commentaire:
Enregistrer un commentaire