title: How to get result in Laravel with where clause while passing model in controller method
body: <p>I have a route to get a single post item by slug.</p>
  
  <h2>Route</h2>
  
  <pre><code>Route::get('post/{post}', 'PostController@details')-&gt;name('post.details');
  </code></pre>
  
  <p>While I want to pass the model in the controller method for the route.</p>
  
  <h2>Controller</h2>
  
  <pre><code>public function details(Post $post)
  {
      // how to get the post by slug
  }
  </code></pre>
  
  <blockquote>
    <p><strong>My question</strong> is how can I get the post by slug passing in the route
    instead of post ID?</p>
  </blockquote>
  
  <p>I am aware that I can pass the slug and get the post using where clause.</p>
  
  <pre><code>//Route
  Route::get('post/{slug}', 'PostController@details')-&gt;name('post.details');
  
  //Controller method
  public function details($slug)
  {
      $post = Post::with('slug', $slug)-&gt;first();
  }
  </code></pre>
  
  <p>But I want to learn to do the same by passing the Model in the method.</p>