Example #1
0
 public function getMenuOptions()
 {
     $opts = array();
     $page = new PageRepository(new Page());
     $pageOpts = $page->lists();
     foreach ($pageOpts as $k => $v) {
         $opts['Page']['App\\Models\\Page-' . $k] = $v;
     }
     $photoGallery = new PhotoGalleryRepository(new PhotoGallery());
     $photoGalleryOpts = $photoGallery->lists();
     foreach ($photoGalleryOpts as $k => $v) {
         $opts['PhotoGallery']['App\\Models\\PhotoGallery-' . $k] = $v;
     }
     $menuOptions = array('General' => array('home' => 'Home', 'news' => 'News', 'blog' => 'Blog', 'project' => 'Project', 'faq' => 'Faq', 'contact' => 'Contact'), 'Page' => isset($opts['Page']) ? $opts['Page'] : array(), 'Photo Gallery' => isset($opts['PhotoGallery']) ? $opts['PhotoGallery'] : array());
     return $menuOptions;
 }
Example #2
0
 public function update($id, $request)
 {
     $menu = $this->find($id);
     $menu->status = $request->get('status');
     if ($request->has('parent')) {
         $menu->parent = $request->get('parent');
     }
     $menu->icon = $request->get('icon');
     $menu->type = $request->get('type');
     $menu->type_id = $request->get('type_id');
     $menu->update();
     $syncs = [];
     if ($request->get('type') == 'custom') {
         foreach (get_langs() as $lang) {
             $datalang = $request->get($lang->code);
             $menu_desc = ['name' => $datalang['name'], 'link' => $datalang['link']];
             $syncs[$lang->id] = $menu_desc;
         }
     } else {
         foreach (get_langs() as $lang) {
             $datalang = $request->get($lang->code);
             $type_id = $request->get('type_id');
             switch ($request->get('type')) {
                 case 'page':
                     $pagerepo = new PageRepository(new Page());
                     $page = $pagerepo->get_with_lang($type_id, $lang->code);
                     $link = get_path(route('page.show', ['id' => $type_id, 'slug' => $page->lang->slug]));
                     $name = trim($datalang['name']) == '' ? $page->lang->name : $datalang['name'];
                     break;
                 case 'cat':
                     $catrepo = new TaxRepository(new Tax());
                     $cat = $catrepo->get_with_lang($type_id, $lang->code);
                     $link = get_path(route('cat.show', ['id' => $type_id, 'slug' => $cat->lang->slug]));
                     $name = trim($datalang['name']) == '' ? $cat->lang->name : $datalang['name'];
                     break;
                 case 'services':
                     $services = new ServicesRepository(new Service());
                     $ser = $services->get_with_lang($type_id, $lang->code);
                     $link = get_path(route('services.show', ['id' => $type_id, 'slug' => $ser->lang->slug]));
                     $name = trim($datalang['name']) == '' ? $ser->lang->name : $datalang['name'];
                     break;
                 default:
                     $link = '';
                     $name = '';
                     break;
             }
             $menu_desc = ['name' => $name, 'link' => $link];
             $syncs[$lang->id] = $menu_desc;
         }
     }
     $menu->langs()->sync($syncs);
 }