Answer the question
In order to leave comments, you need to log in
Eloquent ORM, how to link many-to-many tables?
Good afternoon!
There is an Ability model, a method
categories(){
return $this->belongsToMany(
'App\Category', 'ability_category', 'ability_id', 'category_id'
);}
abilities(){
return $this->belongsToMany(
'App\Ability', 'ability_category', 'category_id', 'ability_id'
);}
Answer the question
In order to leave comments, you need to log in
Relationship BelongsToMany Always returns a collection of objects. Therefore, to select a field, you need to refer to an element of this collection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question