/** * Run the database seeds. * * @return void */ public function run() { DB::table('categories')->insert(['created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]); DB::table('category_translations')->insert(['category_id' => 1, 'slug' => 'root', 'name' => 'Root', 'locale' => 'en']); DB::table('category_translations')->insert(['category_id' => 1, 'slug' => 'root', 'name' => 'Root', 'locale' => 'el']); DB::table('category_translations')->insert(['category_id' => 1, 'slug' => 'root', 'name' => 'Root', 'locale' => 'de']); DB::table('categories')->insert(['parent_id' => 1, 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]); DB::table('category_translations')->insert(['category_id' => 2, 'slug' => 'uncategorized', 'name' => 'Uncategorized', 'locale' => 'en']); DB::table('category_translations')->insert(['category_id' => 2, 'slug' => 'uncategorized', 'name' => 'Uncategorized', 'locale' => 'el']); DB::table('category_translations')->insert(['category_id' => 2, 'slug' => 'uncategorized', 'name' => 'Uncategorized', 'locale' => 'de']); \Wislem\Berrier\Models\Category::fixTree(); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $menu = $this->menu->findOrFail($id); $pages = Page::active()->get(); $categories = Category::withDepth()->defaultOrder()->descendantsOf(1)->linkNodes(); return view('berrier::admin.menus.edit')->with(compact('menu'))->with(compact('pages'))->with(compact('categories')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $response = ['error' => 0, 'msg' => '']; if ($id == 1) { return redirect('admin/categories')->withErrors(['general' => 'Didn\'t I say, DO NOT DELETE THE ROOT CATEGORY?????']); } try { $category = Category::findOrFail($id); $category->delete(); if (Category::isBroken()) { Category::fixTree(); } } catch (\Exception $e) { return redirect('admin/categories')->withErrors(['general' => 'Something went wrong: ' . $e->getMessage()]); } return redirect('admin/categories')->with('success', 'Category deleted successfully'); }
function beautifyMenuitems($menuitems) { if (!$menuitems) { return array(); } foreach ($menuitems as $item) { $split = explode(':', $item->id); $item->title = ''; switch ($split[0]) { case 'Page': $item->title = \Wislem\Berrier\Models\Page::where('id', '=', $split[1])->first()->title; break; case 'Category': $item->title = \Wislem\Berrier\Models\Category::where('id', '=', $split[1])->first()->name; break; case 'Url': $url_attributes = explode('|', $split[1] . $split[2]); $item->title = $url_attributes[1]; break; default: break; } if (isset($item->children)) { $item->children = beautifyMenuitems($item->children); } } return $menuitems; }
<?php Route::get('admin/fixtree', function () { \Wislem\Berrier\Models\Category::fixTree(); }); Route::get('admin/auth/login', ['uses' => 'Wislem\\Berrier\\Http\\Controllers\\AuthController@getLogin']); Route::post('admin/auth/login', ['uses' => 'Wislem\\Berrier\\Http\\Controllers\\AuthController@postLogin']); Route::get('admin/auth/logout', ['uses' => 'Wislem\\Berrier\\Http\\Controllers\\AuthController@getLogout']); Route::group(['prefix' => 'admin', 'namespace' => 'Wislem\\Berrier\\Http\\Controllers', 'middleware' => 'berrier.auth'], function () { Route::get('/', ['uses' => 'BerrierController@dashboard']); Route::post('ajax/slug-it', ['uses' => 'AjaxController@slugIt']); Route::resource('categories', 'Modules\\Categories\\CategoryController', ['except' => 'show']); Route::patch('categories/{id}/move', ['uses' => 'Modules\\Categories\\CategoryController@move']); Route::resource('pages', 'Modules\\Pages\\PageController', ['except' => 'show']); Route::post('pages/grid', 'Modules\\Pages\\PageController@grid'); Route::resource('posts', 'Modules\\Posts\\PostController', ['except' => 'show']); Route::post('posts/grid', 'Modules\\Posts\\PostController@grid'); Route::resource('menus', 'Modules\\Menus\\MenuController', ['except' => 'show']); Route::post('menus/grid', 'Modules\\Menus\\MenuController@grid'); Route::resource('widgets', 'Modules\\Widgets\\WidgetController', ['except' => 'show']); Route::post('widgets/grid', 'Modules\\Widgets\\WidgetController@grid'); Route::resource('settings', 'Modules\\Settings\\SettingController', ['except' => 'show']); Route::post('settings/grid', 'Modules\\Settings\\SettingController@grid'); Route::resource('users', 'Modules\\Users\\UserController', ['except' => 'show']); Route::post('users/grid', 'Modules\\Users\\UserController@grid'); Route::resource('usettings', 'Modules\\UserSettings\\UserSettingController', ['except' => 'show']); Route::post('usettings/grid', 'Modules\\UserSettings\\UserSettingController@grid'); Route::resource('notifications', 'Modules\\Notifications\\NotificationController', ['except' => 'show']); Route::resource('media', 'Modules\\Media\\MediaController', ['only' => ['store', 'destroy']]); }); Route::get('{slug}', ['uses' => 'Wislem\\Berrier\\Http\\Controllers\\Modules\\Pages\\PageFrontController@index']);
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $widget = $this->widget->findOrFail($id); $pages = Page::join('page_translations as t', 't.page_id', '=', 'pages.id')->lists('title', 'id')->toArray(); $posts = Post::join('post_translations as t', 't.post_id', '=', 'posts.id')->lists('title', 'id')->toArray(); $categories_tree = Category::withDepth()->defaultOrder()->descendantsOf(1)->linkNodes(); $categories = renderTreeToOptions($categories_tree); return view('berrier::admin.widgets.edit')->with(compact('pages'))->with(compact('categories'))->with(compact('posts'))->with(compact('widget')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $post = $this->post->with('categories', 'media')->findOrFail($id); $categories_tree = Category::withDepth()->defaultOrder()->descendantsOf(1)->linkNodes(); $categories = renderTreeToOptions($categories_tree); return view('berrier::admin.posts.edit')->with(compact('post'))->with(compact('categories')); }