Пример #1
0
 public function Parallax()
 {
     $menus = Menu::roots()->get();
     $menu = Menu::where('slug', '/anasayfa')->first();
     \Activity::log('Ziyaret: Anasayfa (Tek Sayfa Site)');
     return view('parallax')->with(['menus' => $menus, 'menu' => $menu]);
 }
Пример #2
0
 public function show($id)
 {
     $menu = Menu::where('fecha', '2015-11-7')->first();
     $relaciones = $menu->menu_platos;
     foreach ($relaciones as $relacion) {
         switch ($relacion->plato->tipo->id) {
             case 1:
                 $entradas[] = $relacion->plato;
                 break;
             case 2:
                 $segundos[] = $relacion->plato;
                 break;
             case 3:
                 $postres[] = $relacion->plato;
                 break;
             case 4:
                 $bebidas[] = $relacion->plato;
                 break;
         }
     }
     switch ($id) {
         case 1:
             return $entradas;
         case 2:
             return $segundos;
         case 3:
             return $postres;
         case 4:
             return $bebidas;
     }
 }
Пример #3
0
 public function __construct()
 {
     // Carbon Language
     Carbon::setLocale('tr');
     // create home page if non exist
     count(Menu::where('slug', '/anasayfa')->get()) == 0 ? Menu::create(['title' => 'Anasayfa', 'slug' => '/anasayfa', 'eng_title' => 'Home', 'eng_slug' => '/home'])->save() : null;
     // create config file if non exist
     !\File::exists(storage_path('.config')) ? \File::put(storage_path('.config'), json_encode(['brand' => 'Brand Name', 'mail' => '*****@*****.**', 'active' => 1, 'eng' => '0', 'one_page' => '0', 'googlemap' => '', 'header' => ''])) : null;
     $this->config = json_decode(\File::get(storage_path('.config')));
     !\File::exists(storage_path('app/custom/css')) ? \File::makeDirectory(storage_path('app/custom/css'), 0755, true) : null;
     !\File::exists(storage_path('app/custom/js')) ? \File::makeDirectory(storage_path('app/custom/js'), 0755, true) : null;
     // get css & js files from custom folder
     // css
     $css = \File::allFiles(storage_path('app/custom/css'));
     if (!empty($css)) {
         foreach ($css as $cs) {
             $this->css[$cs->getCtime()] = $cs->getRelativePathname();
         }
         // sort by date
         ksort($this->css);
     }
     // js
     $js = \File::allFiles(storage_path('app/custom/js'));
     if (!empty($js)) {
         foreach ($js as $j) {
             $this->js[$j->getCtime()] = $j->getRelativePathname();
         }
         // sort by date
         ksort($this->js);
     }
 }
Пример #4
0
 public function __construct()
 {
     $this->menus = Menu::where('pid', '=', '0')->orderBy('odnum', 'asc')->get();
     //主菜单
     $this->pidmenus = Menu::where('pid', '!=', '0')->orderBy('odnum', 'asc')->get();
     //子菜单
     View::share(['menus' => $this->menus, 'pidmenus' => $this->pidmenus]);
 }
Пример #5
0
 public function deleteMenu()
 {
     $id = (int) Input::get('id');
     $menu = Menu::where('parent', $id);
     if (!$menu->exists()) {
         Menu::destroy($id);
     }
     return 1;
 }
Пример #6
0
 public function headerPageName($route_name)
 {
     if (!is_null($route_name)) {
         // DB::enableQueryLog();
         // dd(DB::getQueryLog());
         $menuDescription = Menu::where('rota', $route_name)->get()->first();
         $headerText = "<h1>" . $menuDescription->nome . "<small>" . $menuDescription->descricao . "</small></h1>";
         return $headerText;
     }
 }
Пример #7
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $menu = Menu::findOrFail($id);
     $data = ['id' => $id];
     foreach (array_keys($this->fields) as $field) {
         $data[$field] = old($field, $menu->{$field});
     }
     $parent_list = Menu::where('parent_id', '=', 0)->where('id', '!=', $id)->orderBy('order', 'asc')->select('id', 'title')->get();
     return view('admin.menu.edit', $data)->with('parent_list', $parent_list);
 }
Пример #8
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $tags = Tag::lists('tag')->all();
     view()->composer('index', view()->share('tags', $tags));
     //后台菜单
     $menus = Menu::where('parent_id', '=', 0)->orderBy('order', 'asc')->get();
     foreach ($menus as &$value) {
         $value['child_list'] = Menu::where('parent_id', '=', $value['id'])->where('status', '=', 1)->orderBy('order', 'asc')->get();
     }
     view()->composer('admin', view()->share('menus', $menus));
 }
Пример #9
0
 /**
  * Handle the event.
  *
  * @param  CreateMenuEvent  $event
  * @return void
  */
 public function handle(CreateMenuEvent $event)
 {
     // return array([
     //     'icon'  => 'fa-user',
     //     'title' => 'Settings'
     //     ],
     //     [
     //     'icon'  => 'fa-trash-o',
     //     'title' => 'Settings',
     //     'children'  => array(
     //         'General' => '[url]',
     //         'Blog' => '[url]'
     //     )],
     //      [
     //     'icon'  => 'fa-trash-o',
     //     'title' => 'Settings',
     //     'children'  => array(
     //         'Haha' => '[url]',
     //         'Blog' => '[url]'
     //     )]
     // );
     $user = $event->user;
     $menu = [];
     $user = User::find($user->id);
     $main = Menu::where('is_main', '=', 1)->get()->toArray();
     foreach ($main as $item) {
         $role = [];
         $role = Role::find($item['role']);
         $child = Menu::where('parent', '=', $item['id'])->get()->toArray();
         $me = [];
         if ($user->hasRole($role->name)) {
             $me['icon'] = $item['icon'];
             $me['title'] = $item['name'];
             if (isset($child) && !empty($child)) {
                 foreach ($child as $c) {
                     $permission = Permission::find($c['permission']);
                     if ($user->can($permission->name)) {
                         $me['children'][$c['name']] = $c['route'];
                     } else {
                         continue;
                     }
                 }
             }
         } else {
             continue;
         }
         $menu[] = $me;
     }
     return $menu;
 }
Пример #10
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     //当前路由
     $currentRouteName = Route::currentRouteName();
     $currentRouteName = preg_replace('/(admin)(\\.[a-z]*)(\\.[a-z]*)/', '$1$2', $currentRouteName);
     if (!empty($currentRouteName)) {
         $menu = Menu::where('route_name', '=', $currentRouteName)->first();
         if (!empty($menu)) {
             $fmenu = Menu::where('id', '=', $menu->fid)->first();
             $view->with('menu', $menu)->with('fmenu', $fmenu);
         }
     } else {
         $dash = 'Dashboard';
         $view->with('dash', $dash);
     }
 }
Пример #11
0
 public function menuAction()
 {
     $menu_id = (int) Input::get('id', 0);
     if (!$menu_id) {
         $codemenu = Menu::where('slug', '=', 'civil')->first();
         $menu_id = $codemenu->id;
     }
     $allmenus = Menu::orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
     $menus = $this->clubarr($allmenus);
     $topicarr = Menu::find($menu_id)->topics()->orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
     $topics = $this->clubarr($topicarr);
     $articles = Menu::find($menu_id)->articles()->join('article_contents', 'article_contents.article_id', '=', 'articles.id')->get(['articles.*', 'article_contents.title'])->toArray();
     $viewarr = array('articles' => $articles, 'menus' => $menus, 'menuid' => $menu_id, 'topics' => $topics, 'topicid' => 0);
     \View::share('pagetitle', Menu::find($menu_id)->first()->title);
     return view('civil.menulist')->with($viewarr);
 }
Пример #12
0
	public static function getMenu(){
		$arr_menu = Menu::where('active','=',1)->orderBy('order_no')->get()->toArray();
		$menus= array();
		foreach ($arr_menu as $key => $menu) {
			if($menu['parent_id']==0){
				$menus[$menu['id']] = $menu;
				$menus[$menu['id']]['children'] = array();
			}
		}

		foreach ($arr_menu as $key => $menu) {
			if(isset($menus[$menu['parent_id']])){
				$menus[$menu['parent_id']]['children'][] = $menu;
			}
		}
		return $menus;
	}
Пример #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $menu_id = \App\Menu::where('menu_type', '=', 'Appetizer')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Vegetable Samosa', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcT_e7I4C_lUkMuhsadXSGP4eycr1lw6XVAyoiiOcYkq33C7W2f9']);
     $menu_id = \App\Menu::where('menu_type', '=', 'Drinks')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Thandai', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'http://www.burrp.com/know/wp-content/uploads/2014/03/Almond-Thandai-Cocktail-300x300.jpg']);
     $menu_id = \App\Menu::where('menu_type', '=', 'Paneer Speical')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Paneer Masala', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcStXXrG4yj8m7UwaAa4tw-cJk4EIf84LdvIHkKouZ1wMEm8pgYD']);
     $menu_id = \App\Menu::where('menu_type', '=', 'Daal Speical')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Daal Makhni', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'http://images.tastespotting.com/thumbnails/707997.jpg']);
     $menu_id = \App\Menu::where('menu_type', '=', 'Desserts')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Faluda Malai Kulfi', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSsSJ9C47iOWslT2euXH8jToC9g9VeP1fRJ-gWPDcDS9v9Ly4j7']);
     $menu_id = \App\Menu::where('menu_type', '=', 'Raita')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Boondi Raita', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'https://photo.foodgawker.com/wp-content/uploads/2013/04/1310004.jpeg']);
     $menu_id = \App\Menu::where('menu_type', '=', 'Naan')->pluck('id');
     DB::table('recipes')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'recipe_name' => 'Garlic Naan', 'menu_id' => $menu_id, 'user_id' => 1, 'image_url' => 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQMs89yBUWBiIfjO78oZEXE8hvT3_GOd3wgs_YVy3kxcjqKM9Ml']);
 }
Пример #14
0
 public function addTopic()
 {
     Input::merge(array_map('trim', Input::all()));
     $pageslug = Input::get('pageslug');
     $coremenu = Menu::where('slug', $pageslug)->first();
     if ($coremenu->exists()) {
         $level = (int) Input::get('level');
         $parent = Input::get('id');
         $name = Input::get('val');
         $mn = new Topic();
         $mn->menu_id = $coremenu->id;
         $mn->title = ucwords($name);
         $mn->parent = $parent;
         $mn->level = $level;
         $mn->save();
     }
     return 1;
 }
Пример #15
0
 /**
  * Create a new profile composer.
  *
  * @param  Resquest  $request
  * @return void
  */
 public function __construct(Request $request)
 {
     $this->menus = Menu::where('ativo', 1)->get();
     // Dependencies automatically resolved by service container...
     $usuario = $request->user();
     $grupos = [];
     $grupos_usuario = UsuarioGrupo::where('usuario', $usuario->id)->get();
     if ($grupos_usuario) {
         foreach ($grupos_usuario as $g) {
             $grupos[] = $g->grupo;
         }
     }
     $grupos_permissao = GrupoPermissao::where('grupo', $grupos)->get();
     if ($grupos_permissao) {
         foreach ($grupos_permissao as $gp) {
             $this->permissao[] = $gp->menu;
         }
     }
 }
Пример #16
0
 public function scrape5CMenu()
 {
     $client = new Client();
     $crawler = $client->request('GET', 'https://aspc.pomona.edu/menu/');
     $status_code = $client->getResponse()->getStatus();
     if ($status_code == 200) {
         echo '200 OK<br>';
     }
     $date = substr(Carbon::today(), 0, 10);
     $crawler->filter('table')->last()->filter('tr')->each(function ($row) use($date) {
         $count = 0;
         $row->filter('td ul')->each(function ($node, $count) use($date) {
             $diningHall = substr($node->parents()->parents()->attr('id'), 0, -5);
             $node->filter('li')->each(function ($node1) use($count, $diningHall, $date) {
                 if ($count == 0) {
                     $meal = 'breakfast';
                 } elseif ($count == 1) {
                     $meal = 'lunch';
                 } else {
                     $meal = 'dinner';
                 }
                 $food = $node1->text();
                 echo "For " . $meal . " we have " . $food . " at " . $diningHall;
                 echo "<br>";
                 $count++;
                 $store_id = DB::table('stores')->where('sh_name', $diningHall)->value('store_id');
                 $id = DB::table('email_articles')->where('post_date', $date)->value('article_id');
                 if (Menu::where('foodName', $food)->where('meal', '=', $meal)->where('article_id', $id)->where('store_id', $store_id)->exists()) {
                     echo $food . " already exists for " . $meal . " on" . $date;
                 } else {
                     $entry = new Menu();
                     $entry->article_id = $id;
                     $entry->store_id = $store_id;
                     $entry->foodName = $food;
                     $entry->meal = $meal;
                     $entry->save();
                     echo $food . " saved for " . $diningHall . " id " . $store_id;
                 }
             });
         });
     });
 }
Пример #17
0
 public static function jsonMenu()
 {
     $menus = Menu::where('depth', 1)->where('status', 1)->where('belong_to', 'enterprise')->get();
     $submenus = Menu::where('depth', 2)->where('status', 1)->where('belong_to', 'enterprise')->get();
     function getSubs($subs, $mid)
     {
         $submenu = array();
         foreach ($subs as $sub) {
             if ($sub->parent_id == $mid) {
                 array_push($submenu, $sub);
             }
         }
         return $submenu;
     }
     $subList = array();
     foreach ($menus as $menu) {
         $subList[$menu->id] = getSubs($submenus, $menu->id);
     }
     return ['menus' => $menus, 'submenus' => $subList];
 }
Пример #18
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $main = Menu::where('is_main', '=', 1)->get()->toArray();
     foreach ($main as $item) {
         $child = Menu::where('parent', '=', $item['id'])->get()->toArray();
         $me = [];
         $me['icon'] = $item['icon'];
         $me['title'] = $item['name'];
         $me['id'] = $item['id'];
         if (isset($child) && !empty($child)) {
             foreach ($child as $c) {
                 $me['children'][$c['name']] = $c['id'];
             }
         }
         $menu[] = $me;
     }
     // return $menu;
     // dd($menu);
     return view('menu.index', ['menu' => $menu]);
 }
Пример #19
0
 public function getSolicitar()
 {
     // Listado de combos
     $combos = Combo::all();
     // Variables a llenar
     $platos = [];
     $entradas = [];
     $segundos = [];
     $postres = [];
     $bebidas = [];
     // Menu del día
     $carbon = Carbon::now('America/Lima');
     $fechaActual = $carbon->toDateString();
     $menu = Menu::where('fecha', $fechaActual)->first();
     $hora = $carbon->toTimeString();
     if ($menu) {
         $relaciones = $menu->menu_platos;
         foreach ($relaciones as $relacion) {
             $platos[] = $relacion->plato;
             switch ($relacion->plato->tipo->descripcion) {
                 case "Entradas":
                     $entradas[] = $relacion->plato;
                     break;
                 case "Segundos":
                     $segundos[] = $relacion->plato;
                     break;
                 case "Postres":
                     $postres[] = $relacion->plato;
                     break;
                 case "Bebidas":
                     $bebidas[] = $relacion->plato;
                     break;
             }
         }
     }
     return view('user.solicitar')->with(compact(['hora', 'combos', 'entradas', 'segundos', 'postres', 'bebidas', 'platos']));
 }
 /**
  * 输出添加菜单界面
  * 
  * @param        
  * 
  * @author        wen.zhou@bioon.com
  * 
  * @date        2015-10-18 12:17:23
  * 
  * @return        
  */
 public function getAdd()
 {
     $parents = Menu::where('parent_id', '<=', 1)->get();
     $permissions = Permission::all();
     $returnData = ['parents' => $parents, 'permissions' => $permissions];
     return view('admin.menu.add')->with($returnData);
 }
Пример #21
0
 public function postAsignarPlatos($dia, $tipo, Request $request)
 {
     $asignar = $request->get('asignar');
     $carbon = Carbon::now()->startOfWeek();
     switch ($dia) {
         case 'lunes':
             $adicionales = 0;
             break;
         case 'martes':
             $adicionales = 1;
             break;
         case 'miercoles':
             $adicionales = 2;
             break;
         case 'jueves':
             $adicionales = 3;
             break;
         case 'viernes':
             $adicionales = 4;
             break;
         case 'sabado':
             $adicionales = 5;
             break;
         case 'domingo':
             $adicionales = 6;
             break;
     }
     $carbon = $carbon->addDays($adicionales);
     $menu = Menu::where('fecha', $carbon->toDateString())->first();
     if ($asignar == 1) {
         $relacion = MenuPlatos::create(['menu_id' => $menu->id, 'plato_id' => $request->get('plato_id')]);
         if ($relacion) {
             return ['exito' => true];
         }
         return ['exito' => false];
     } else {
         $relacion = MenuPlatos::where('menu_id', $menu->id)->where('plato_id', $request->get('plato_id'))->first();
         $relacion->delete();
         return ['exito' => true];
     }
 }
Пример #22
0
 public function menu()
 {
     $menus = Menu::where('menu_id', 0)->orderBy('ordem', 'asc')->get();
     return view('sistema.menu', compact('menus'));
 }
Пример #23
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $this->authorize(new Permissions());
     $Item = Modules::find($id);
     $this->authorize('editRecord', $Item);
     //validate if user editing is the creator of the item.
     $MenuList = Menu::where('mn_enabled', '1')->select('id', 'mn_name', 'mn_description')->get();
     view()->share('MenuList', $MenuList);
     $mdlList = Modules::where('mdl_enabled', '1')->where('mdl_menu', '1')->where('id', '<>', $id)->where('id', '<>', '4')->select('id', 'mdl_name')->get();
     return view('admin.modules.edit')->with('Item', $Item)->with('mdlList', $mdlList);
 }
Пример #24
0
 public function saveMenu($button_list)
 {
     Menu::where("mp_id", $this['id'])->delete();
     foreach ($button_list as $k => $button) {
         $new_btn = array('type' => isset($button['type']) ? $button['type'] : "", 'name' => $button['name'], 'key' => isset($button['key']) ? $button['key'] : "", 'url' => isset($button['url']) ? $button['url'] : "", 'order' => $k, 'parent' => 0, 'mp_id' => $this['id']);
         $parent_btn = Menu::create($new_btn);
         if (count($button['sub_button']) > 0) {
             foreach ($button['sub_button'] as $i => $child_button) {
                 $new_btn = array('type' => isset($child_button['type']) ? $child_button['type'] : "", 'name' => $child_button['name'], 'key' => isset($child_button['key']) ? $child_button['key'] : "", 'url' => isset($child_button['url']) ? $child_button['url'] : "", 'order' => $i, 'parent' => $parent_btn['id'], 'mp_id' => $this['id']);
                 Menu::create($new_btn);
             }
         }
     }
 }
Пример #25
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return \App\Menu::where('admin_id', \Auth::user()->admin_id)->where('status', 1)->first()->categories;
 }
Пример #26
0
 /**
  * Get all
  * @return Collection
  */
 public function getParents()
 {
     $menus = Menu::where('parentMenu', 0)->get();
     return $menus;
 }
Пример #27
0
 public function updateMenu(Request $request, $id)
 {
     /*DB::transaction(function () use ($request){
               //1. CHECKING VALIDATION
               $this->validate($request, [
                   'title' => 'required',
                   'position' => 'required',
                   'type' => 'required',
                   'status' => 'required',
                   'menu_id' => 'required'
               ]);
               
               //2. GET ALL REQUESTS AND CREATE MENU OBJECT
               $input = $request->except('_token','menu_id');
               if($request->input('parent_id')==''){
                   $input = $request->except('parent_id','_token','menu_id');
               }
       
               //3. GET MENU
               $menu = Menu::where([
                   'id'=> $request->input('menu_id'),
                   'status' => 1
               ])->firstOrFail();
               
               //4. CHECK MENU
               if($menu!=null){
                   //5. GET MENU TRANSLATION
                   $menuTranslations = MenuTranslation::where([
                           'menu_id' => $request->input('menu_id'),
                           'language_id' => 'en'
                       ]);
                   //6. CHECK MENU TRANSLATION
                   if($menuTranslations==null){
                       
                   }else{
                       //7. SET UPDATED USER TO THE MENU
                       $input['updated_by'] = Auth::user()->id;
                       //8. UPDATE MENU
                       $menu->update($input);
                       //9. UPDATE MENUTRANSLATIONS
                       $menuTranslations->update($request->only('title','content'));
                   }
                   //10. FLASH MESSAGE BACK
                   Session::flash('flash_message', 'Menu successfully updated!');
               }else{
                   //11. FLASH MESSAGE BACK
                   Session::flash('flash_message', 'Menu not found!!!');
               }*/
     DB::transaction(function () use($request) {
         //1. CHECKING VALIDATION
         $this->validate($request, ['title' => 'required', 'position' => 'required', 'type' => 'required', 'status' => 'required', 'menu_id' => 'required', 'parent_id' => 'numeric', 'ordering' => 'required|numeric']);
         //2. GET ALL REQUESTS AND CREATE MENU OBJECT
         $input = $request->except('_token', 'menu_id');
         if ($request->input('parent_id') == '') {
             $input = $request->except('parent_id', '_token', 'menu_id');
             $input['parent_id'] = NULL;
         } else {
             $menuParent = Menu::find($request->input('parent_id'));
             $input['level'] = ++$menuParent->level;
         }
         //3. GET MENU
         $menu = Menu::where(['id' => $request->input('menu_id')])->firstOrFail();
         //4. CHECK MENU
         if ($menu != null) {
             //7. SET UPDATED USER TO THE MENU
             $input['updated_by'] = Auth::user()->id;
             //8. UPDATE MENU
             $menu->update($input);
             //10. FLASH MESSAGE BACK
             Session::flash('flash_message', 'Menu successfully updated!');
         } else {
             //11. FLASH MESSAGE BACK
             Session::flash('flash_message', 'Menu not found!!!');
         }
     });
     //12. REDIRECT BACK
     return redirect()->back();
 }
Пример #28
0
 public function postEditMenu($id)
 {
     if (\Auth::check()) {
         $data = Input::all();
         array_pop($data);
         $rules = ['menu_name' => 'required', 'content' => 'required'];
         $validator = Validator::make($data, $rules);
         if ($validator->fails()) {
             return Redirect::back()->withErrors($validator->errors())->withInput();
         } else {
             $menu = Menu::where('id', $id)->first();
             $menu->menuname = $data['menu_name'];
             $menu->content = $data['content'];
             $menu->status = $data['status'];
             $menu->save();
             return redirect('view_menus');
         }
     } else {
         return redirect('login');
     }
 }
Пример #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function getParentMenu($lokasi)
 {
     $Menus = Menu::where('parent_id', 0)->where('lokasi', $lokasi)->get();
     return view('admin.layout.inc.getParentMenu', ['Menus' => $Menus]);
 }
Пример #30
0
 public function createArticle()
 {
     $art_id = Input::get('id', 0);
     if (Request::isMethod('post')) {
         $menuslug = Input::get('menu', 0);
         $topic = Input::get('topic', 0);
         if ($menuslug && $topic) {
             $coremenu = Menu::where('slug', $menuslug)->first();
             $menu_id = $coremenu->id;
             if ($art_id && $coremenu->exists()) {
                 // edit
                 // article
                 $art_obj = Article::find($art_id);
                 $art_obj->update(array('menu_id' => $menu_id, 'topic_id' => $topic));
                 // article content
                 $artcontObj = $art_obj->articlecontent()->update(array('title' => Input::get('title'), 'content' => Input::get('content')));
                 // article menu reference
                 $formarr = Input::get('formarr');
                 $references = $formarr['reference'];
                 if (isset($references) && !empty($references)) {
                     $art_obj->menu_relations()->detach();
                     foreach ($references as $reference_id) {
                         $art_obj->menu_relations()->attach($reference_id);
                     }
                 }
             } else {
                 // add
                 // article
                 $art_obj = new Article();
                 $art_obj->menu_id = $menu_id;
                 $art_obj->topic_id = $topic;
                 $art_obj->save();
                 $art_id = $art_obj->id;
                 // article content
                 $artcontObj = new ArticleContent();
                 $artcontObj->article_id = $art_id;
                 $artcontObj->title = Input::get('title');
                 $artcontObj->content = Input::get('content');
                 $artcontObj->save();
                 // article menu reference
                 $formarr = Input::get('formarr');
                 $references = $formarr['reference'];
                 if (isset($references) && !empty($references)) {
                     $art_obj->menu_relations()->detach();
                     foreach ($references as $reference_id) {
                         $art_obj->menu_relations()->attach($reference_id);
                     }
                 }
             }
             return redirect()->to("/admin/article/listing?menu={$menuslug}&topic={$topic}&page=1")->with('onetime.success', "article " . $art_id . " saved");
         }
     }
     $poparr = array('references' => array(), 'article' => array());
     if ($art_id) {
         $article_references = Article::find($art_id)->menu_relations()->get();
         $references = array();
         foreach ($article_references as $refer) {
             $poparr['references'][] = $refer->id;
         }
         $poparr['article'] = $article = Article::where('articles.id', $art_id)->join('article_contents', 'article_contents.article_id', '=', 'articles.id')->get(['articles.*', 'article_contents.title', 'article_contents.content'])->first()->toArray();
         // $poparr['article'] = $this->formatCode($article);
     }
     $allmenus = Menu::where('level', '<', 2)->orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
     $sorted_menus = $this->clubarr($allmenus);
     return view('admin.article.create')->with(array('id' => $art_id, 'menus' => $sorted_menus, 'populate' => $poparr));
 }