I'm using Laravel 5.5 I have a 'Post' Model. In that model I want to use a Route Parameter (say userId).. I have this id in Post Controller.
public function getPosts($userId)
{
$posts = Post::latest()->paginate(8);
return Response::json($posts);
}
I want to use the $userId in the Post Model to get some more information. How do I access this parameter from the Post model? Should I use session to store the userId value and try to use it? Is there any other way?