title: How to use Traits - Laravel 5.2
body: <p>I'm new to Traits, but I have a lot of code that is repeating in my functions, and I want to use Traits to make the code less messy. I have made a <code>Traits</code> directory in my <code>Http</code> directory with a Trait called <code>BrandsTrait.php</code>. And all it does is call on all Brands. But when I try to call BrandsTrait in my Products Controller, like this:</p>
  
  <pre><code>use App\Http\Traits\BrandsTrait;
  
  class ProductsController extends Controller {
  
      use BrandsTrait;
  
      public function addProduct() {
  
          //$brands = Brand::all();
  
          $brands = $this-&gt;BrandsTrait();
  
          return view('admin.product.add', compact('brands'));
      }
  }
  </code></pre>
  
  <p>it gives me an error saying <strong>Method [BrandsTrait] does not exist.</strong> Am I suppose to initialize something, or call it differently?</p>
  
  <p>Here is my <code>BrandsTrait.php</code></p>
  
  <pre><code>&lt;?php
  namespace App\Http\Traits;
  
  use App\Brand;
  
  trait BrandsTrait {
      public function brandsAll() {
          // Get all the brands from the Brands Table.
          Brand::all();
      }
  }
  </code></pre>