title: Laravel - Get Route Parameter in a Model
body: <p>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.</p>
  
  <pre><code>public function getPosts($userId)
  {      
      $posts = Post::latest()-&gt;paginate(8);
      return Response::json($posts);
  }
  </code></pre>
  
  <p>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?</p>