title: Eloquent Laravel show Trying to get property 'code' of non-object
body: <p>I have 2 model created like below: </p>
  
  <p><code>Employee.php</code></p>
  
  <pre><code>&lt;?php
  namespace App;
  use Illuminate\Database\Eloquent\Model;
  
  class Employee extends Model
  {
      public function grades(){
          return $this-&gt;belongsTo(Grade::class);
      }
  }
  </code></pre>
  
  <p>and also</p>
  
  <p><code>Grade.php</code></p>
  
  <pre><code>&lt;?php
  
  namespace App;
  use Illuminate\Database\Eloquent\Model;
  
  class Grade extends Model
  {
      public function employee(){
          return $this-&gt;hasMany(Employee::class);
      }
  }
  </code></pre>
  
  <p>when I try to show code ane name of Grade in tinker like below <p></p>
  
  <pre><code>$a=App\Employee::find(15);&lt;br&gt;
  $a-&gt;grades-&gt;code
  </code></pre>
  
  <p>it gives me error :</p>
  
  <blockquote>
    <p>PHP Notice:  Trying to get property 'code' of non-object in Psy Shell code on line 1*</p>
  </blockquote>
  
  <p><code>table employees</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/dxXlr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dxXlr.jpg" alt="employees"></a></p>
  
  <p><code>table grades</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/hKTHI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hKTHI.jpg" alt="grades"></a></p>