Model function :
class Cart extends Model
{
public static function cart()
{
$id = \Auth::user()->id;
$count = Cart::where('user_id' , $id)->sum('quantity');
return $count;
}
}
But it shows Trying to get property 'id' of non-object at view page. Please help me how to solve this?