/**
  * create new category
  * @param  Requests\CategoryChangeRequest $request validated form
  * @return redirect to category page
  */
 public function postCreateCategory(Requests\CategoryChangeRequest $request)
 {
     $category = new Category();
     $category->fill($request->all());
     $category->save();
     return redirect()->action('Resource\\DashboardController@getIndexByCategory', ['category_id' => $category->id]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Category::create(['title' => 'science']);
     Category::create(['title' => 'history']);
     Category::create(['title' => 'mathematics']);
     Category::create(['title' => 'art']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = User::find(1);
     if (!$user) {
         $user = factory('KnowTube\\User')->create();
     }
     $category = Category::find(1);
     if (!$category) {
         $category = factory('KnowTube\\Category')->create();
     }
     factory('KnowTube\\Resource')->create(['title' => 'good ol rick', 'url' => 'https://www.youtube.com/embed/dQw4w9WgXcQ', 'user_id' => $user->id, 'category_id' => $category->id]);
     factory('KnowTube\\Resource', 5)->create(['user_id' => $user->id, 'category_id' => $category->id]);
 }
 /**
  * display resources filtered by a category
  * @param  $category_id id of category to filter by
  * @return view
  */
 public function getIndexByCategory($category_id)
 {
     $resources = Category::findOrFail($category_id)->resources;
     return view('resource.index', ['resources' => $resources, 'categories' => $this->categories]);
 }