/** * Execute the command. * * @return void */ public function handle() { $post = Post::where('slug', $this->old_slug)->first(); $post->category_id = $this->category_id; $post->name = $this->name; $post->slug = $this->slug; $post->content = $this->content; $post->save(); }
/** * 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() { Post::where('slug', $this->slug)->first()->delete(); }
/** * Display the specified resource. * * @param string $slug * @return Response */ public function show($category) { return view('index', ['posts' => Post::where('category_id', $category->id)->with('category')->orderBy('created_at', 'DESC')->paginate(5)]); }