Example #1
0
 public function run()
 {
     Category::truncate();
     $categories = ['General'];
     foreach ($categories as $category) {
         Category::create(['name' => $category, 'slug' => Str::slug($category)]);
     }
 }
 public function compose($view)
 {
     $categories = Category::lists('name', 'id');
     $view->with(compact('categories'));
 }
 /**
  * Store a newly created category in storage.
  *
  * @return Response
  */
 public function store(Create $request)
 {
     $data = $request->all();
     $category = Category::create($data);
     return $this->redirect('categories.index');
 }
Example #4
0
 /**
  * Remove the specified category from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         Category::destroy($id);
         return $this->redirect('categories.index');
     } catch (ModelNotFoundException $e) {
         return $this->redirectNotFound();
     }
 }