public function scopeOwner($query, $id)
{
return $query->where('user_id', $id);
}
public static function getTicket($id)
{
$ticket = Support::where('id', $id)->owner(Auth::user()->id)->first();
return $ticket;
}
You can also do this
public static function getTicket($id)
{
$ticket = static::where('id', $id)->owner(auth()->id())->first();
return $ticket;
}