/** * Страница создания категории. * * @return \Illuminate\View\View */ public function getCreate() { // Ищем фирму по короткому названию $data['company'] = Company::whereShortTitle($this->companyName)->first(); // Возможные родительские категории $data['parent_categories'] = Category::whereNull('parent_id')->orderBy('title')->get(); // Группы категорий $data['groups_categories'] = GroupsCategory::whereCompanyId($data['company']->id)->orderBy('title')->get(); return view('admin.companies.catalog.categories.create', $data); }
public function search(Request $request) { $menu = \App\Menu::find(1); $search = $request->input('search') ?: ''; /*$categories = \App\Category::where('level','1')->orderBy('ordering')->get(); $parentCategory = \App\Category::where('title','like','%'.$search.'%') ->orWhereIn('parent_id',DB::table('categories')->where('title',$search)->lists('id')) ->lists('id');*/ $categories = \App\Category::whereNull('deleted_at')->get(); $contents = \App\Content::where('title', 'like', '%' . $search . '%')->whereNull('deleted_at')->orderBy('created_at')->paginate(21); return view('project_list')->with(['category' => '', 'categories' => $categories, 'contents' => $contents, 'menu' => $menu]); }
Route::get('/projectsinfo', function () { return view('project_info'); }); Route::get('/about', function () { return view('about'); }); Route::get('/home', function () { return view('welcome'); }); Route::get('menu/{menuId}/categories/{categoryId}/projects/{projectId?}', function ($menuId, $categoryId, $projectId = '') { $menu = \App\Menu::find($menuId); $category = \App\Category::find($categoryId); $categories = \App\Category::where('level', '1')->where('parent_id', $menu->internal_url)->whereNull('deleted_at')->orderBy('ordering')->get(); if ($projectId == '') { $parentCategory = \App\Category::where('parent_id', $categoryId)->orWhereIn('parent_id', DB::table('categories')->where('parent_id', $categoryId)->whereNull('deleted_at')->lists('id'))->whereNull('deleted_at')->lists('id'); $parentCategorySup = \App\Category::whereNull('deleted_at')->where('parent_id', 'in', implode(' ,', $parentCategory->toArray()))->lists('id'); $contents = \App\Content::where('category_id', $categoryId)->orWhereIn('category_id', $parentCategory->toArray())->whereNull('deleted_at')->orderBy('created_at')->paginate(21); return view('project_list')->with(['category' => $category, 'categories' => $categories, 'contents' => $contents, 'menu' => $menu]); } else { $content = \App\Content::find($projectId); return view('project_info')->with(['category' => $category, 'categories' => $categories, 'content' => $content, 'menu' => $menu]); } })->where(['menuId' => '[0-9]+', 'categoryId' => '[0-9]+', 'projectId' => '[0-9]+']); Route::get('categories/projects/search', 'CategoryController@search'); Route::post('menu/{menuId}/categories/{categoryId}/projects', function ($menuId, $categoryId) { $parentCategory = \App\Category::where('parent_id', $categoryId)->orWhereIn('parent_id', DB::table('categories')->where('parent_id', $categoryId)->lists('id'))->whereNull('deleted_at')->lists('id'); $contents = \App\Content::where('category_id', $categoryId)->orWhereIn('category_id', $parentCategory->toArray())->whereNull('deleted_at')->orderBy('created_at')->paginate(21); $data = View('project_list_template')->with(['contents' => $contents, 'menu' => \App\Menu::find($menuId)])->render(); return response()->json($data); }); Route::get('locale/{locale?}', ['as' => 'locale.setocale', 'uses' => 'LocaleController@setLocale']);