title: laravel 5 get current language id in controller
body: <p>i'm new to laravel, and i'm wondering how to get the language_id (primary key "id" in database) by current lang_code (a column of language table).</p>
  
  <p>in my language model, i created a function like this :</p>
  
  <pre><code>public function getLang($lang_code = null) {
       $lang_code = App::getLocale();
       return SELF::with($lang_code)-&gt;get();
  }
  </code></pre>
  
  <p>in the homeController, i added this line of code:</p>
  
  <pre><code>    $lang = Language::with('getLang');
      echo $lang-&gt;id;
  </code></pre>
  
  <p>Got errors:</p>
  
  <pre><code>at HandleExceptions-&gt;handleError('8', 'Undefined property: Illuminate\Database\Eloquent\Builder::$id', '/home/otherraylinux/public_html/starter/app/Http/Controllers/HomeController.php', '52', array('articles' =&gt; object(Collection), 'lang' =&gt; object(Builder))) in HomeController.php line 52
  </code></pre>
  
  <p><em>edit</em>
  The actual things i want to do is:</p>
  
  <pre><code>$lang = DB::table('languages')-&gt;select('id')-&gt;where('lang_code', '=', App::getLocale())-&gt;get();
  echo $lang[0]-&gt;id;
  </code></pre>
  
  <p><em>edit</em></p>
  
  <p>What is the problem? And what is the best practice to get the id ? i know the above code should not be good in practice.</p>