Inheritance: extends BaseModel
Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $menu = new Menu();
     $menu->event_id = 1;
     $menu->menu_name = "Test Menu";
     $menu->save();
 }
Example #3
0
 /**
  * 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']);
 }
Example #4
0
 public function __construct(Menu $menuModel, Slider $slider)
 {
     $this->data['menu']['left'] = $menuModel->getLeftMenu();
     $this->data['menu']['right'] = $menuModel->getRightMenu();
     $this->data['slider'] = $slider->getActive();
     $URL = $_SERVER['REQUEST_URI'];
     $this->data['url_lang'] = substr($URL, 1, 2);
 }
Example #5
0
 /**
  * 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;
 }
Example #6
0
 public function update(Request $request, $menuId)
 {
     $info = $request->only('info');
     $menu = Menu::find($menuId);
     $menu->update($info['info']);
     return view('message', ['msg' => '操作成功', 'redirect' => route('menus.index')]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function __construct()
 {
     $setting = Models\Setting::first();
     $this->data['menu'] = Models\Menu::with('child')->where('level', 0)->get();
     $this->data['berita'] = Models\Berita::orderBy('id_berita', 'desc')->limit(6)->get();
     $this->data['pengumuman'] = Models\Pengumuman::orderBy('tanggal', 'desc')->limit(10)->get();
     $this->data['agenda'] = Models\Agenda::orderBy('tgl_posting', 'desc')->limit(5)->get();
     $this->data['polling'] = Models\Polling::with('jawaban')->where('status', 'Y')->limit(1)->first();
     $this->data['title'] = $setting->title_web;
     $this->data['desc'] = $setting->desc_web;
     $this->data['key'] = $setting->key_web;
     $this->data['logo'] = $setting->logo;
     $this->data['header_img'] = $setting->bg_header;
     $this->data['icon'] = $setting->favicon;
     $this->data['facebook'] = $setting->facebook;
     $this->data['peta_latitude'] = $setting->peta_latitude;
     $this->data['peta_longitude'] = $setting->peta_longitude;
     $this->data['twitter'] = $setting->twitter;
     $this->data['gplus'] = $setting->gplus;
     $this->data['slider_home'] = Models\Berita::orderBy('tanggal', 'desc')->limit(5)->get();
     $this->data['galeri_home'] = Models\Foto::OrderBy('id_foto', 'desc')->paginate(9);
     $this->data['opini_home'] = Models\Berita::where('kategori_berita', 5)->orderBy('id_berita', 'desc')->limit(6)->get();
     $this->data['banner'] = Models\Banner::where('id', 1)->first();
     $this->data['link'] = Models\Link::orderBy('id', 'desc')->limit(5)->get();
     $this->data['publikasi'] = Models\Publikasi::orderBy('id', 'desc')->limit(3)->get();
     $this->data['setting'] = $setting;
 }
Example #8
0
 public function boot()
 {
     view()->composer('*', function ($view) {
         $menuId = request()->get('menuid');
         $routeName = app('router')->currentRouteName();
         if (empty($menuId)) {
             $menuId = app('menu')->select('id')->where('route', '=', $routeName)->first()['id'];
         }
         $params = ['submenus' => [], 'route_name' => $routeName, 'menuid' => $menuId];
         if (!empty($menuId)) {
             $menus = Menu::all();
             $submenus = [];
             foreach ($menus as $menu) {
                 if ($menu['parentid'] == $menuId) {
                     $submenus[] = $menu;
                 }
                 if ($menu['id'] == $menuId) {
                     $p = $menu;
                 }
             }
             array_unshift($submenus, $p);
             $params['submenus'] = $submenus;
         }
         $view->with($params);
     });
 }
Example #9
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     //查询当前登录用户
     $admin = Auth::guard('admin')->user();
     if ($admin->admin_name == 'admin') {
         $menus = Menu::orderBy('sort', 'ASC')->get()->toTree();
     } else {
         if ($admin->role) {
             $ids = DB::table('sys_role_function')->where('sys_role_id', $admin->role[0]->id)->pluck('sys_fun_id');
             $menus = Menu::orderBy('sort', 'ASC')->whereIn('id', $ids)->get()->toTree();
         }
     }
     $currentRoute = Route::currentRouteName();
     $list = explode('.', $currentRoute);
     $route = '';
     for ($i = 0; $i < count($list) - 1; $i++) {
         if ($i == 0) {
             $route .= $list[$i];
         } else {
             $route .= '.' . $list[$i];
         }
     }
     $route = $route . '.index';
     $view->with('currentRoute', $route)->with('trees', $menus);
 }
Example #10
0
 public function run()
 {
     $menu = Menu::find()->where(['position' => 'bottom'])->one();
     $p = explode(',', $menu->content);
     $model = Page::find()->where(['id' => $p])->all();
     return $this->render('links', ['pages' => $model]);
 }
Example #11
0
 public static function getChildMenu($ParentId, $ParentLabel)
 {
     $menuData = Menu::find()->where(['ismenu' => TRUE, 'status' => TRUE, 'parentid' => $ParentId, 'isweb' => FALSE])->orderBy('orderby')->all();
     $submenu = array();
     $menu = array();
     if (!empty($menuData)) {
         foreach ($menuData as $mKey => $mValue) {
             $menu['label'] = Html::tag('i', '', ['class' => $mValue['labelicon']]) . Html::encode($mValue['label']);
             $urlArray = [$mValue['module'], $mValue['controller'], $mValue['action']];
             $menu['url'] = \Yii::$app->urlManager->createUrl(implode('/', $urlArray));
             $class = '';
             if (\Yii::$app->controller->id == $urlArray[1] && \Yii::$app->controller->action->id == $urlArray[2]) {
                 $class = 'active';
                 \Yii::$app->params['breadcrumbs'][] = $ParentLabel;
                 \Yii::$app->params['breadcrumbs'][] = $mValue['label'];
             }
             $menu['options'] = ['class' => $class];
             $submenu[$mValue['orderby']] = $menu;
             unset($menu, $urlArray);
         }
         // $submenu['options'] = ['class' => 'children'];
     }
     return $submenu;
     //, 'options' => ['class' => 'children']];
 }
 public function destroy($id)
 {
     //
     $data = Menu::find($id);
     if ($data->delete()) {
         return response()->json(array('success' => TRUE, 'msg' => 'Data Berhasil Dihapus'));
     }
 }
Example #13
0
 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');
 }
Example #14
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function __construct()
 {
     $this->data['menu'] = Models\Menu::with('child')->where('level', 0)->get();
     $this->data['berita'] = Models\Berita::orderBy('tanggal', 'desc')->limit(4)->get();
     $this->data['pengumuman'] = Models\Pengumuman::orderBy('tanggal', 'desc')->limit(5)->get();
     $this->data['agenda'] = Models\Agenda::orderBy('tgl_posting', 'desc')->limit(5)->get();
     $this->data['polling'] = Models\Polling::with('jawaban')->where('status', 'Y')->limit(1)->first();
 }
Example #15
0
 protected function findModel($id)
 {
     if (($model = Menu::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $eventSlug, $menuId)
 {
     $this->menu = Menu::findOrFail($menuId);
     $this->menu->fill($request->input());
     $this->menu->save();
     return redirect()->back()->with('message', 'Menu name updated');
     //Do this homie
 }
Example #17
0
 public function postDestroy()
 {
     $menu = Menu::find(Input::get('id'));
     if ($menu) {
         $menu->delete();
         return Redirect::back()->with('message', 'Элемент меню удален');
     }
     return Redirect::back()->with('message', "Ошибка");
 }
Example #18
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Menu::create(['key' => '', 'name' => 'Главная', 'sort' => '1']);
     Menu::create(['key' => 'catalog', 'name' => 'Каталог', 'sort' => '2']);
     Menu::create(['key' => 'delivery', 'name' => 'Доставка и оплата', 'sort' => '3']);
     Menu::create(['key' => 'orderFurniture', 'name' => 'Мебель на заказ', 'sort' => '4']);
     Menu::create(['key' => 'wholesalers', 'name' => 'Оптовикам', 'sort' => '5']);
     Menu::create(['key' => 'contacts', 'name' => 'Контакты', 'sort' => '6']);
 }
Example #19
0
 /**
  * @param Category $except
  *
  * @return CategoriesController
  */
 protected function getCategoryOptions($except = null)
 {
     /** @var \Kalnoy\Nestedset\QueryBuilder $query */
     $query = Menu::select('id', 'fun_name')->withDepth();
     if ($except) {
         $query->whereNotDescendantOf($except)->where('id', '<>', $except->id);
     }
     return $this->makeOptions($query->get());
 }
Example #20
0
 public function validateUrl($attribute, $params)
 {
     $row = Menu::findOne(['url' => $this->url]);
     if ($row) {
         //if ($row->id != $this->post_id){
         $this->addError($attribute, 'Пункт меню с таким URI уже существует.');
         //}
     }
 }
 public function getAll()
 {
     $top = DB::table('toplinks')->get();
     $links = $this->fetchTable(Menu::all());
     $sublinks = $this->getSublinks();
     $title = $this->getTitle('Home');
     $Links = array('titletest' => $title, 'menu' => $links, 'sublinks' => $sublinks, 'toplinks' => $top);
     return $Links;
 }
Example #22
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  MenuItemRequest  $request
  * @return Response
  */
 public function store(MenuItemRequest $request, $eventSlug, $menuId)
 {
     $this->menuItem->newInstance();
     $menu = Menu::findOrFail($menuId);
     $this->menuItem->fill($request->input());
     $this->menuItem->menu_id = $menu->id;
     $this->menuItem->save();
     return redirect()->route('event.{eventSlug}.menu.index', [$menu->event->slug])->with(compact('menu', 'event'));
 }
Example #23
0
 /**
  * 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');
 }
Example #24
0
 /**
  * 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;
 }
Example #25
0
 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;
 }
Example #26
0
 function actionAdminList()
 {
     $query = new Query();
     $query->addSelect('c.*')->from([Menu::tableName() . ' c']);
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100]]);
     $model = new MenuForm();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $object = new Menu();
         $object->name = $model->name;
         $object->url = $model->url;
         $object->sort_int = 0;
         $object->active = 1;
         $object->parent_id = 0;
         $object->save();
         $model->command_reload_page = 1;
         //return $this->redirect(Url::toRoute(['posts/menu-list']));
     }
     $this->layout = 'admin';
     return $this->render('//admin/menu/list.php', ['provider' => $provider, 'model' => $model]);
 }
Example #27
0
 /**
  * @param Menu $menuModel
  * @param Slider $slider
  * @param Alphabet $alphabet
  * @param Song $song
  * @param Performer $performer
  * @param Lessons $lessons
  * @param Request $request
  */
 public function __construct(Menu $menuModel, Slider $slider, Alphabet $alphabet, Song $song, Performer $performer, Lessons $lessons, Request $request)
 {
     $this->performer = $performer;
     #Models performer
     $this->song = $song;
     #Models song
     $this->lessons = $lessons;
     #Models lessons
     $this->request = $request;
     #request
     $this->data['menu']['left'] = $menuModel->getLeftMenu();
     $this->data['menu']['right'] = $menuModel->getRightMenu();
     $this->data['slider'] = $slider->getActive();
     $this->data['alphabet'] = $alphabet->getActive();
     $this->data['countPerformer'] = count($performer->getActive());
     $this->data['countSong'] = count($song->getActive());
     $this->data['countLessons'] = count($lessons->getAll());
     $URL = $_SERVER['REQUEST_URI'];
     $this->data['url_lang'] = substr($URL, 1, 2);
 }
Example #28
0
 public function loadSettings()
 {
     echo 'loadSettings(company) exit';
     exit;
     //load also income maps
     $settings = array();
     if (Yii::$app->db->schema->getTableSchema('{{config}}') !== null) {
         Yii::$app->session['menu'] = Menu::buildUserMenu();
     }
     //Yii::$app->session['settings'] = $settings;
 }
Example #29
0
 public function actionPage($slug)
 {
     $page = Page::find()->where(['slug' => $slug])->one();
     if ($slug == 'home') {
         return $this->goHome();
     }
     if (Yii::$app->deviceDetect->isMobile()) {
         $this->layout = "//mobile";
         $mobile = 'mobile/';
     } else {
         $this->layout = "//inner";
         $mobile = '';
     }
     if ($page->parent_id == 0) {
         $menu = Menu::find()->where(['position' => 'bottom'])->one();
         $links = explode(',', $menu->content);
         if ($page->id == 13) {
             $group_news = Post::find()->where(['page_id' => 14])->orderBy(['create_date' => SORT_DESC])->all();
             $industry_news = Post::find()->where(['page_id' => 15])->orderBy(['create_date' => SORT_DESC])->limit(6)->all();
             $media_news = Post::find()->where(['page_id' => 16])->orderBy(['create_date' => SORT_DESC])->limit(6)->all();
             $pic_news = Photo::find()->where(['page_id' => 39, 'parent_id' => 0])->orderBy(['create_date' => SORT_DESC])->limit(10)->all();
             $headlines = Post::find()->where(['is_headline' => 1])->orderBy(['create_date' => SORT_DESC])->all();
             return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'group_news' => $group_news, 'industry_news' => $industry_news, 'media_news' => $media_news, 'pic_news' => $pic_news, 'headlines' => $headlines]);
         } else {
             if (in_array($page->id, $links)) {
                 return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'menu' => Page::find()->where(['id' => $links])->all()]);
             }
         }
         $menu = Page::find()->where(['parent_id' => $page->id])->orderBy(['display_order' => SORT_ASC])->all();
         $s = $menu ? $menu[0]->slug : null;
         return $this->redirect(['page', 'slug' => $s]);
     } else {
         $menu = Page::find()->where(['parent_id' => $page->parent_id])->orderBy(['display_order' => SORT_ASC])->all();
     }
     if ($page->type == 3) {
         //新闻列表
         $query = Post::find()->where(['page_id' => $page->id]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 12, 'totalCount' => $countQuery->count()]);
         $posts = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
         return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'menu' => $menu, 'pnation' => $pnation, 'posts' => $posts]);
     } else {
         if ($page->type == 4) {
             //相册列表
             $query = Photo::find()->where(['page_id' => $page->id, 'parent_id' => 0]);
             $countQuery = clone $query;
             $pnation = new Pagination(['defaultPageSize' => 9, 'totalCount' => $countQuery->count()]);
             $albums = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
             //            $albums = Photo::find()->where(['page_id'=>$page->id,'parent_id'=>0])->orderBy(['create_date'=>SORT_DESC])->all();
             return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'albums' => $albums, 'pnation' => $pnation, 'menu' => $menu]);
         }
     }
     return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'menu' => $menu]);
 }
Example #30
0
 public function index()
 {
     //Get Menu Lists
     if ($this->auth->check()) {
         $status = "logined";
     } else {
         $status = "unlogin";
     }
     $this->login = $status;
     $menu = Menu::with('SubMenu')->get();
     return response()->json($menu);
 }