title: laravel 5 display books with author name
body: <p>How do I display books with the author name?<br>
  Here is my model:</p>
  
  <p><strong>Book.php</strong></p>
  
  <pre><code>public function authors()
  {
         return $this-&gt;belongsTo('App\Author');
  }
  </code></pre>
  
  <p><strong>Author.php</strong></p>
  
  <pre><code>public function books()
  {
          return $this-&gt;hasMany('App\Book');
  }
  </code></pre>
  
  <p>My controller:</p>
  
  <p><strong>BookController.php</strong></p>
  
  <pre><code>use App\Author;
  
  
  public function index()
  {
      foreach (Book::with('authors')-&gt;get() as $book)
      {
          echo $book-&gt;authors-&gt;name;
      }
  }
  </code></pre>
  
  <p><strong>ERROR</strong></p>
  
  <blockquote>
    <p>Trying to get property of non-object</p>
  </blockquote>
  
  <p>Please HELP what might be the problem?</p>