title: How to use variables as attribute name in Laravel Eloquent
body: <p>Is there anyway to use variables in eloquent
  Example:</p>
  <pre class="lang-php prettyprint-override"><code>public function showLessons($skill)
      {
          $user = (\App\User::where('id', Auth::user()-&gt;getId())-&gt;first());
          $type = $user-&gt;type;
          if ($type === &quot;student&quot;) {
              $bs = ($user-&gt;student_bronze_ . $skill);
              $ss = ($user-&gt;student_silver_ . $skill);
              $gs = ($user-&gt;student_gold_ . $skill);
          } elseif ($type === &quot;school&quot;) {
              $bs = ($user-&gt;school_bronze_ . $skill);
              $ss = ($user-&gt;school_silver_ . $skill);
              $gs = ($user-&gt;school_gold_ . $skill);
          };
          return view('pages.lessons', compact(&quot;bs&quot;, &quot;ss&quot;, &quot;gs&quot;));
      }
  </code></pre>
  <p>I am trying to check if the user's level is the same or higher than the lesson's id</p>