Conditionnal relationship

Submitted by Matt - 5 years ago

It's possible to add condition to your model's relationships... Help me to use Eloquent with a legacy database..

class myModel extents Model
{
    ...
    
    public function category() {
    	return $this->belongsTo('myCategoryModel', 'categories_id')->where('users_id', Auth::user()->id);
	}
    
    ...
}
comments powered by Disqus