/** * Execute the command. * * @return void */ public function handle() { $category = Category::find($this->id); $category->name = $this->name; $category->slug = $this->slug; $category->save(); }
/** * 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); }
/** * 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(); }); }
/** * Execute the command. * * @return void */ public function handle() { Category::create(['name' => $this->name, 'slug' => $this->slug]); }
/** * 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()]); }
/** * Execute the command. * * @return void */ public function handle() { Category::find($this->id)->delete(); }