title: Laravel where has passing additional arguments to function
body: <p>The following obviously results in undefined variable.</p>
  
  <pre><code>public function show($locale, $slug)
  {
   $article = Article::whereHas('translations', function ($query) {
   $query-&gt;where('locale', 'en')
    -&gt;where('slug', $slug);
   })-&gt;first();
  
     return $article;
  }
  </code></pre>
  
  <p>Trying to supply the function with the $slug variable:</p>
  
  <pre><code>public function show($locale, $slug)
  {
      $article = Article::whereHas('translations', function ($query, $slug) {
          $query-&gt;where('locale', 'en')
          -&gt;where('slug', $slug);
      })-&gt;first();
  
      return $article;
  }
  </code></pre>
  
  <p>results in </p>
  
  <pre><code>Missing argument 2 for App\Http\Controllers\ArticlesController::App\Http\Controllers\{closure}()
  </code></pre>
  
  <p>how can you allow the funtion to have access to $slug?
  Now this is probably something simple but I cant find what i need to search for.</p>