For the products model
public function categories()
{
return $this->belongsTo('Categories', 'category_id');
}
And Categories model
public function products()
{
return $this->hasMany('Product', 'category_id');
}
I don't understand what you try to achieve in the view. Where was $category defined?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community