當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Menu::where方法代碼示例

本文整理匯總了PHP中app\models\Menu::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Menu::where方法的具體用法?PHP Menu::where怎麽用?PHP Menu::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Menu的用法示例。


在下文中一共展示了Menu::where方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     // Log action by user.
     Audit::log(Auth::user()->id, trans('admin/menu-builder/menu-builder.audit-log.category'), trans('admin/menu-builder/menu-builder.audit-log.msg-index'));
     // Set page title and description.
     $page_title = trans('admin/menu-builder/menu-builder.page.index.title');
     $page_description = trans('admin/menu-builder/menu-builder.page.index.description');
     // Load all menus ordered by Parent (asc), Position (asc), Label (asc) and finally ID (asc).
     $menus = Menu::orderBy('parent_id', 'ASC')->orderBy('position', 'ASC')->orderBy('label', 'ASC')->orderBy('id', 'ASC')->get();
     // Convert menu query result to JSON for JSTree
     $menusJson = $this->menusOrmToJsTreeJson($menus);
     // List label and id of all menus ordered by Label (asc).
     $parents = Menu::where('separator', '0')->orderBy('label', 'ASC')->orderBy('id', 'ASC')->get()->lists('label', 'id');
     // Convert to array.
     $parents = $parents->toArray();
     // List name and id of all routes ordered by Name (asc).
     $routes = Route::whereNotNull('name')->orderBy('name', 'ASC')->get()->lists('name', 'id');
     // Convert to array.
     $routes = $routes->toArray();
     // Add a blank option at the top.
     $routes = array('blank' => '') + $routes;
     // List display name and id of all permissions ordered by Name (asc).
     $permissions = Permission::orderBy('name', 'ASC')->get()->lists('display_name', 'id');
     // Convert to array.
     $permissions = $permissions->toArray();
     // Add a blank option at the top.
     $permissions = array('blank' => '') + $permissions;
     // Return view
     return view('admin.menus.index', compact('menus', 'menusJson', 'parents', 'routes', 'permissions', 'page_title', 'page_description'));
 }
開發者ID:sroutier,項目名稱:laravel-5.1-enterprise-starter-kit,代碼行數:33,代碼來源:MenusController.php

示例2: __construct

 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct(LaravelFacebookSdk $fb, Menu $menu, ProjectRepository $project_repo)
 {
     $this->middleware('auth');
     $this->menuItems = $menu->where('active', '1')->orderBy('weight', 'asc')->get();
     $this->login_url = $fb->getLoginUrl(['email']);
     $this->project_repo = $project_repo;
 }
開發者ID:udayc,項目名稱:travel,代碼行數:12,代碼來源:CheckoutController.php

示例3: __construct

 /**
  * Create a new authentication controller instance.
  *
  * @param  \Illuminate\Contracts\Auth\Guard  $auth
  * @param  \Illuminate\Contracts\Auth\Registrar  $registrar
  * @return void
  */
 public function __construct(Guard $auth, Registrar $registrar, Menu $menu)
 {
     $this->auth = $auth;
     $this->registrar = $registrar;
     $this->menuItems = $menu->where('active', '1')->orderBy('weight', 'asc')->get();
     $this->middleware('guest', ['except' => 'getLogout']);
 }
開發者ID:udayc,項目名稱:travel,代碼行數:14,代碼來源:AuthController.php

示例4: content

 public function content($slug)
 {
     $menu_item = Menu::where('url', $slug);
     if ($menu_item->count()) {
         return view('home.content', ['menu_item' => $menu_item->first()]);
     }
     return view('errors.404');
 }
開發者ID:venomir,項目名稱:venomir.com,代碼行數:8,代碼來源:MenuController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $eventId)
 {
     $menu = Menu::where('event_id', '=', $eventId)->get()->first();
     if (!$menu) {
         return $this->respondNotFound('Menu does not exist');
     }
     $menu_name = $menu->menu_name;
     $menu->delete();
     return $this->respondDeleteSuccess($menu_name . ' deleted');
 }
開發者ID:rob-meh,項目名稱:table-seater,代碼行數:16,代碼來源:MenuController.php

示例6: generateMenu

 public function generateMenu()
 {
     $menu = Menu::where('pid', '=', 0)->orderBy('id', 'asc')->get();
     foreach ($menu as $k => $item) {
         $menu[$k]['sub'] = Menu::where('pid', '=', $item->id)->orderBy('id', 'asc')->get();
         if (count($menu[$k]['sub']) < 1) {
             unset($menu[$k]['sub']);
         }
     }
     return $menu;
 }
開發者ID:Comrada,項目名稱:laravel-cms,代碼行數:11,代碼來源:MenuGenerator.php

示例7: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     //if(!parent::authorize()) return false;
     if ($this->menu) {
         if ($this->user()->isAdmin()) {
             return true;
         }
         return Menu::where('id', $this->menu)->where('user_id', $this->user()->id)->exists();
     }
     return true;
 }
開發者ID:udayc,項目名稱:travel,代碼行數:16,代碼來源:MenuRequest.php

示例8: testExample

 /**
  * A basic test example.
  *
  * @return void
  */
 public function testExample()
 {
     //$this->assertTrue(true);
     //Unauthorized access
     $this->visit('/admin')->seePageIs('login');
     //Logging as Admin
     $admin = User::where('is_admin', '1')->first();
     $this->actingAs($admin)->visit('/admin')->seePageIs('admin');
     $this->actingAs($admin)->visit('/admin/pages/main')->see('Главная страница');
     $this->actingAs($admin)->visit('/admin/pages/main/edit')->see('Редактирование главной страницы');
     $this->actingAs($admin)->visit('/admin/pages/static')->see('Статические страницы');
     try {
         //Opening static page editor
         $static_page = Page::where('id', '>', 1)->firstOrFail();
     } catch (ModelNotFoundException $e) {
     } finally {
         $this->actingAs($admin)->visit('/admin/pages/static/' . $static_page->id . '/edit')->see('Редактирование страницы');
         unset($static_page);
     }
     $this->actingAs($admin)->visit('/admin/pages/static')->click('Создать')->see('Создание страницы');
     $this->actingAs($admin)->visit('/admin/menu')->see('Редактор меню');
     //Create new menu item
     $this->actingAs($admin)->visit('/admin/menu')->click('Создать')->see('Новый пункт меню')->select(0, 'pid')->type('Тест', 'name')->type('test357', 'url')->press('Создать')->seePageIs('/admin/menu');
     try {
         //Delete created item
         $menu = Menu::where('url', 'test357')->firstOrFail();
     } catch (ModelNotFoundException $e) {
     } finally {
         $this->actingAs($admin)->delete('/admin/menu/' . $menu->id);
         $this->assertResponseStatus(302);
         $this->assertRedirectedToRoute('admin.menu');
         $this->followRedirects()->see('Редактор меню');
         unset($menu);
     }
     //File manager
     $this->actingAs($admin)->visit('/admin/files')->see('Файловый менеджер');
     //Users
     $this->actingAs($admin)->visit('/admin/users')->see('Пользователи');
     try {
         //Editing myself
         $user = User::where('id', $admin->id)->firstOrFail();
     } catch (ModelNotFoundException $e) {
     } finally {
         $this->actingAs($admin)->visit('/admin/users/' . $admin->id . '/edit')->see('Редактирование пользователя')->press('Обновить')->seePageIs('/admin/users');
         unset($user);
     }
     //Logout
     $this->actingAs($admin)->visit('/logout')->seePageIs('/');
     //Logging as User
     $user = User::where('is_admin', '0')->first();
     $this->actingAs($user)->get('/admin')->seeStatusCode('403');
     $this->actingAs($user)->visit('/logout')->seePageIs('/');
 }
開發者ID:Comrada,項目名稱:laravel-cms,代碼行數:58,代碼來源:AdminTest.php

示例9: _moveMenuItem

 private function _moveMenuItem($menu_id, $operator)
 {
     $menu = Menu::find($menu_id);
     $order = $operator == '>' ? 'asc' : 'desc';
     $neighbour = Menu::where('sort', $operator, $menu->sort)->orderBy('sort', $order)->first();
     if (empty($neighbour)) {
         return false;
     }
     $old_sort = $menu->sort;
     $menu->sort = $neighbour->sort;
     $neighbour->sort = $old_sort;
     $menu->save();
     $neighbour->save();
     return true;
 }
開發者ID:garf,項目名稱:0ez,代碼行數:15,代碼來源:MenuController.php

示例10: __construct

 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct(LaravelFacebookSdk $fb, Menu $menu, UserRepository $userrepo, ProjectRepository $project_repo)
 {
     $this->middleware('auth');
     $this->menuItems = $menu->where('active', '1')->orderBy('weight', 'asc')->get();
     $this->login_url = $fb->getLoginUrl(['email']);
     $this->userrepo = $userrepo;
     $this->project_repo = $project_repo;
     $id = Auth::user()->id;
     $userProfile = Profile::where('user_id', $id)->first();
     $errorNotification = '0';
     if ($userProfile->f_name == '' || $userProfile->l_name == '' || $userProfile->dob == '0000-00-00' || $userProfile->about_me == '' || $userProfile->first_address == '' || $userProfile->alternate_address == '' || $userProfile->state == '' || $userProfile->zipcode == '' || $userProfile->user_avtar == '') {
         $errorNotification = '1';
     }
     $this->errorNotification = $errorNotification;
 }
開發者ID:udayc,項目名稱:travel,代碼行數:20,代碼來源:HomeController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, $eventId)
 {
     $input = Input::except('token');
     $menu = Menu::where('event_id', '=', $eventId)->first();
     $menuItem = new MenuItem();
     if (!$menu->id) {
         return $this->respondNotFound('Menu Not Found');
     }
     $validator = $menuItem->getValidator($input);
     if ($validator->fails()) {
         return $this->respondInvalidData($validator->errors());
     }
     $menuItem->fill($input);
     $menuItem->menu_id = $menu->id;
     $menuItem->save();
     return $this->respondCreateSuccess($menuItem->name . ' created');
 }
開發者ID:rob-meh,項目名稱:table-seater,代碼行數:23,代碼來源:MenuItemController.php

示例12: detail

 public function detail($id)
 {
     $page = 'catalog';
     $title = Menu::where('key', $page)->value('name');
     $menuHtml = $this->menuHtml($page);
     $menuItems = Menu::all();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     $pageInfo = Page::where('key', $page)->first();
     $categories = Category::orderBy('sort', 'asc')->get();
     $product = Product::with(['category', 'color'])->find($id);
     $product->increment('views');
     $recommended = Product::with('category')->take(4)->get();
     $smallCart = $this->smallCart();
     $cartItem = $this->cartItem($product->id);
     $page = $product;
     $page->title = $product->name;
     return view('site.product', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'title' => $title, 'page' => $page, 'product' => $product, 'categories' => $categories, 'recommended' => $recommended, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'currentItem' => $cartItem, 'currentProductCategory' => $product->category]);
 }
開發者ID:pechatny,項目名稱:kolizej,代碼行數:18,代碼來源:CatalogController.php

示例13: _record

 protected function _record($model, $action)
 {
     parent::_record($model, $action);
     $module = $this->modelName;
     if (Input::get('inmenu') && is_array(Input::get('menu'))) {
         $menuSite = \App\Models\Menu::where('element_id', $this->result['model']['id'])->where('module', $module)->get();
         $inMenu = array();
         $isMenu = array();
         foreach ($menuSite as $m) {
             $inMenu[$m->id] = $m->rootNode();
             if (in_array($inMenu[$m->id], Input::get('menu'))) {
                 $isMenu[] = $inMenu[$m->id];
                 $menu = $m;
                 $menu->module = $module;
                 $menu->name = $this->result['model']['name'];
                 $menu->path = $this->result['model']['path'];
                 $model->menu()->save($menu);
             } else {
                 $m->forceDelete();
             }
         }
         $newMenu = array_diff(Input::get('menu'), $isMenu);
         foreach ($newMenu as $mn) {
             $menu = new \App\Models\Menu();
             $menu->module = $module;
             $menu->name = $this->result['model']['name'];
             $menu->path = $this->result['model']['path'];
             $menu->parent = $mn;
             if ($this->result['model']['parent']) {
                 $parent = \App\Models\Menu::where('element_id', $this->result['model']['parent'])->where('module', $module)->get();
                 foreach ($parent as $m) {
                     $node = $m->rootNode();
                     if ($node == $mn) {
                         $menu->parent = $m->id;
                     }
                 }
             }
             $model->menu()->save($menu);
         }
     }
     return $this->result();
 }
開發者ID:hramose,項目名稱:Admin-2,代碼行數:42,代碼來源:Menu.php

示例14: getIndex

 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function getIndex()
 {
     $menuItems = Menu::where('active', '1')->orderBy('weight', 'asc')->get();
     return view('welcome', ['_featuredProducts' => count($this->Projectlist(Null, 'popular')) > 0 ? (object) $this->Projectlist(Null, 'popular') : $this->Projectlist(Null, 'popular'), '_recently_added' => count($this->Projectlist(Null, 'latest')) > 0 ? (object) $this->Projectlist(Null, 'latest') : $this->Projectlist(Null, 'latest'), '_menus' => $menuItems, 'login_url' => $this->login_url, '_categoryLists' => Category::where('active', '1')->orderBy('id', 'asc')->get(), '_genreLists' => Genre::where('active', '1')->orderBy('id', 'asc')->get(), '_projectLists' => count($this->Projectlist()) > 0 ? (object) $this->Projectlist() : $this->Projectlist(), '_sliders' => Banner::where('active', '1')->orderBy('weight', 'asc')->get()]);
 }
開發者ID:udayc,項目名稱:travel,代碼行數:10,代碼來源:WelcomeController.php

示例15: menuDelete

 public function menuDelete($id)
 {
     try {
         $menu = Menu::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return response('Page not found.', 404);
     }
     if ($menu->pid == 0) {
         Menu::where('pid', '=', $menu->id)->delete();
     }
     $menu->delete();
     return redirect()->route('admin.menu');
 }
開發者ID:Comrada,項目名稱:laravel-cms,代碼行數:13,代碼來源:AdminController.php


注:本文中的app\models\Menu::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。