/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); $router->model('article', 'LTF\\Article'); $router->bind('article_slug', function ($slug) { return Article::findBySlugOrFail($slug); }); $router->model('category', 'LTF\\Category'); $router->bind('category_slug', function ($slug) { return Category::findBySlugOrFail($slug); }); $router->model('language', 'LTF\\Language'); $router->model('page', 'LTF\\Page'); $router->bind('page_slug', function ($slug) { return Page::findBySlugOrFail($slug); }); $router->model('setting', 'LTF\\Setting'); $router->model('user', 'LTF\\User'); }
/** * Save the page ordering * * @param Request $request */ public function postOrder(Request $request) { if ($request->ajax()) { $pages = json_decode($request->getContent()); foreach ($pages as $p) { $page = Page::findOrFail($p->id); $page->lft = $p->lft; $page->rgt = $p->rgt; $page->parent_id = $p->parent_id != "" ? $p->parent_id : null; $page->depth = $p->depth; $page->save(); } } }