title: Laravel 5 Inverse of belongsToMany
body: <p>actually not sure if I am doing it correctly or there are other ways. What I have in my database are the following</p>
  
  <pre><code>brands
      id: integer
      name: string
      slug: string
      description: string
      timestamp
  
  products
      id: integer
      name: string
      price: decimal
      slug: string
      description: string
      timestamp
  
  brand_product
      id: integer
      brand_id: unsignedInteger
      product_id: unsignedInteger
  </code></pre>
  
  <p>Basically, brands have many products, so on my Brand model</p>
  
  <pre><code>...
  public function products()
  {
      return $this-&gt;belongsToMany(Product::class);
  }
  ...
  </code></pre>
  
  <p>However, a Product has one (1) Brand model. Pretty sure I can achieve what I want by adding <code>brand_id</code> on my <code>products</code> table and do the relationship thing on my Product model. However, I have an above database structure. What I did, on my Product model:</p>
  
  <pre><code>...
  protected $appends = ['brand'];
  
  public function brand()
  {
      return $this-&gt;belongsToMany(Brand::class);
  }
  
  public function getBrandAttribute()
  {
      return $this-&gt;brand()-&gt;first();
  }
  ...
  </code></pre>