title: Class 'App\Http\Controllers\App\Category' not found
body: <p>I'm trying to query all products from a category and it's subcategories.
  But I'm getting this error on my Controller.</p>
  
  <pre><code>Class 'App\Http\Controllers\App\Category' not found
  </code></pre>
  
  <p>I have a products table</p>
  
  <pre><code>id
  name
  category_id (fk)
  </code></pre>
  
  <p>And a categories table:</p>
  
  <pre><code>id
  name
  parent_id
  </code></pre>
  
  <p>So if the categories looked like this:</p>
  
  <pre><code>id | title | parent
  1  | Electronics | null
  2  | Smartphones | 1
  3  | Android   | 2
  4  | Clothes   | null
  </code></pre>
  
  <p>And products:</p>
  
  <pre><code>id | title | category_id (fk)
  1  | Smartphone1 | 3
  1  | Smartphone2 | 2
  </code></pre>
  
  <p>This is my code on how to do this:</p>
  
  <p>The Category Model - app/category.php</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class category extends Model
  {
      //
      protected $fillable = array('id', 'name', 'parent_id', 'image_url');
  
  
      public function products()
      {
          // Build an array containing the parent category ID and all subcategory IDs found
          $categoryIds = array_merge([$this-&gt;id], $this-&gt;subcategoryIds());
  
          // Find all products that match the retrieved category IDs 
          return Product::whereIn('category_id', $categoryIds)-&gt;get();
      }
  
      protected function subcategoryIds($id = null, &amp;$ids= [])
      {
          // If no ID is passed, set the current model ID as the parent
          if (is_null($id)) {
              $id = $this-&gt;id;
          }
  
          // Find subcategory IDs
          $categoryIds = $this-&gt;query()-&gt;where('parent', $id)-&gt;lists('id');
  
          // Add each ID to the list and recursively find other subcategory IDs
          foreach ($categoryIds as $categoryId) {
              $ids[] = $categoryId;
              $ids += $this-&gt;subcategoryIds($categoryId, $ids);
          }
  
          return $ids;
      }
  }
  </code></pre>
  
  <p>And on my app/Http/Controllers/ProductController.php</p>
  
  <pre><code>namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  
  use DB;
  use App\Product;
  use App\Category;
  
  use App\Repositories\CategoryRepository;    
  public function getProductsFromCategory()
          {
  
              $id = 1;
              $products = App\Category::find($id)-&gt;products();
              return view('welcome', [
                  'products' =&gt; $products,
              ]);
  
          }
  </code></pre>