title: How to pass a variable into an internal function in Laravel 5.3?
body: <p>I am trying to pass the locale data to the eloquent query but it cannot get it. <code>$locale</code> value is taken from the URI.</p>
  
  <pre><code>class MyController extends Controller
  {
  
      public function index($locale = 'en')
      {
          $news = News::join('categories', 'categories.id', '=', 'news.catid')
              -&gt;select('news.*', 'categories.category')
              -&gt;where([['news.published', '1'], ['news.deleted', '0']])
              -&gt;where(function ($query) {
                  $query-&gt;where('news.language', $locale) //$locale is not recognized naturally
                        -&gt;orWhere('news.language', 'all');
              })
              -&gt;orderBy('news.published_at', 'desc')
              -&gt;take(4)
              -&gt;get();
  
               .
               .
               .
      }
  }
  </code></pre>
  
  <p>How can I pass <code>$locale</code> value into the subquery?</p>