/** * 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('categories', function ($categories) { return Category::where('permalink', $categories)->first(); }); $router->bind('posts', function ($posts) { return Post::where('permalink', $posts)->first(); }); }
/** * Change active Category status * * @param integer $id * @return Response */ public function status($id) { $category = Category::where('id', $id)->select('id', 'name', 'active')->first(); $category->update(['active' => $category->active ? false : true]); $action = $category->active ? 'activó' : 'desactivó'; session()->flash('message', "Se {$action} la categoría \"{$category->name}\" correctamente"); return redirect()->back(); }