I'm trying to learn laravel scoping, I created my first scope but im getting this error message npw
ErrorException in Support.php line 26: Undefined property: Illuminate\Database\Eloquent\Builder::$User
And this is the line
public static function getTicket($id)
{
$ticket = Support::where('id', $id)->User::owner(Auth::user()->id)->first();
return $ticket;
}
and this is in user model
public function scopeOwner($query, $flag)
{
return $query->where('user_id', $flag);
}
Relation between user and support
public function user()
{
return $this->belongsTo('App\User');
}
Can you please explain to me what am i doing wrong ?