Ejemplo n.º 1
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $category = Category::find($this->id);
     $category->name = $this->name;
     $category->slug = $this->slug;
     $category->save();
 }
Ejemplo n.º 2
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     // Retrieve all categories
     $categories = Category::all();
     // Bind them to view
     $view->with('categories', $categories);
 }
Ejemplo n.º 3
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('category', function ($slug) {
         return Category::where('slug', $slug)->first();
     });
     $router->bind('post', function ($slug) {
         return Post::where('slug', $slug)->first();
     });
     $router->bind('page', function ($slug) {
         return Page::where('slug', $slug)->first();
     });
 }
Ejemplo n.º 4
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     Category::create(['name' => $this->name, 'slug' => $this->slug]);
 }
Ejemplo n.º 5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  Post $post
  * @return Response
  */
 public function edit(Post $post)
 {
     return view('post.edit', ['post' => $post, 'categories' => Category::all()]);
 }
Ejemplo n.º 6
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     Category::find($this->id)->delete();
 }