Answer the question
In order to leave comments, you need to log in
How to get the name from a model link?
table company
colum "category"
table category
colum "id", "name"
Company hasMany
public function getCategory(){
return $this->hasMany(Category::class, 'id');
}
Answer the question
In order to leave comments, you need to log in
If your relationship is one to one (each company can have one category)
then so
return $this->hasOne(Category::class, 'id', 'category');
{{$com->getCategory->name}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question