public function run()
 {
     foreach ($this->productsArray as $categoryName => $products) {
         $category = Category::create(['name' => $categoryName]);
         foreach ($products as $productName) {
             $product = new Product(['name' => $productName]);
             $category->products()->save($product);
         }
     }
 }
 /**
  * Find the Category or App Abort 404.
  */
 public function findCategory(Route $route)
 {
     $this->category = Category::findOrFail($route->getParameter('categories'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $categories = Category::paginate(20);
     $this->form_data = ['route' => self::$prefixRoute . 'store', 'method' => 'POST'];
     return $this->getFormView('categories', ['categories' => $categories]);
 }