I created a method in my controller of laravel and want to access userid from session
static function cartItem()
{
$userId=Session::get('cart')['id'];
return Cart::where('user_id', $id)->count();
}
but I am getting this error "Trying to access array offset on value of type null" and I don't know why can anyone help me in this