Exemplo n.º 1
0
 /**
  * the component navigation
  *
  * @return ComponentNavigationCollection
  */
 public function getNavigation()
 {
     // the content builder navigation
     $contentBuilder = new ComponentNavigation('Content Builder', 'fa fa-th-large', url(config('backend.backend.base_url') . '/content_types'));
     $contentBuilder->setRequiredPermissions(['contentBuilder.manage']);
     // the form group:form builder:custom fields
     $formBuilder = new ComponentNavigation('Custom Fields', 'fa fa-list', url(config('backend.backend.base_url') . '/custom_fields'));
     $formBuilder->setRequiredPermissions(['contentBuilder.manage']);
     // the contents navigation
     $contentsNavigation = new ComponentNavigation('Contents', 'fa fa-book', '', true);
     // when "php artisan" command is run, all application registered services are run,
     // so during "php artisan package:publish" stuffs this will throw error as ContentType::all()
     // has no migrations yet. Let's try catch here so we can solve that problem
     try {
         foreach (ContentType::all() as $type) {
             $n = new ComponentNavigation($type->type, 'fa fa-pencil-square', url(config('backend.backend.base_url') . '/contents/' . $type->type));
             // the permission requirements to check
             $permissionManage = $type->type . '.manage';
             $n->setRequiredPermissions([$permissionManage]);
             $contentsNavigation->addSubMenu($n);
         }
     } catch (\Exception $e) {
         // there is an error, do nothing
     }
     $navs = new ComponentNavigationCollection();
     $navs->push($contentBuilder);
     $navs->push($formBuilder);
     $navs->push($contentsNavigation);
     return $navs;
 }