/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // General
     \Solunes\Master\App\Language::create(['code' => 'es', 'name' => 'Español', 'image' => 'es.png']);
     \Solunes\Master\App\Site::create(['name' => 'Plataforma', 'domain' => 'http://master.dev/', 'root' => '/', 'google_verification' => '', 'analytics' => '']);
     // Nodos
     $node_node = \Solunes\Master\App\Node::create(['name' => 'node', 'folder' => 'system']);
     $node_node_requests = \Solunes\Master\App\Node::create(['name' => 'node-request', 'location' => 'package', 'type' => 'subchild', 'parent_id' => $node_node->id]);
     $node_node_extras = \Solunes\Master\App\Node::create(['name' => 'node-extra', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_node->id]);
     $node_filter = \Solunes\Master\App\Node::create(['name' => 'filter', 'folder' => 'system']);
     $node_field = \Solunes\Master\App\Node::create(['name' => 'field', 'type' => 'child', 'location' => 'package', 'parent_id' => $node_node->id]);
     $node_field_extras = \Solunes\Master\App\Node::create(['name' => 'field-extra', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_field->id]);
     $node_field_conditional = \Solunes\Master\App\Node::create(['name' => 'field-conditional', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_field->id]);
     $node_indicator = \Solunes\Master\App\Node::create(['name' => 'indicator', 'folder' => 'system', 'customized' => 1]);
     $node_indicator_alert = \Solunes\Master\App\Node::create(['name' => 'indicator-alert', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_indicator->id]);
     $node_indicator_graph = \Solunes\Master\App\Node::create(['name' => 'indicator-graph', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_indicator->id]);
     $node_indicator_value = \Solunes\Master\App\Node::create(['name' => 'indicator-value', 'type' => 'child', 'location' => 'package', 'parent_id' => $node_indicator->id]);
     $node_site = \Solunes\Master\App\Node::create(['name' => 'site', 'folder' => 'global']);
     $node_page = \Solunes\Master\App\Node::create(['name' => 'page', 'folder' => 'global']);
     $node_menu = \Solunes\Master\App\Node::create(['name' => 'menu', 'folder' => 'global']);
     $node_section = \Solunes\Master\App\Node::create(['name' => 'section', 'folder' => 'global']);
     $node_permission = \Solunes\Master\App\Node::create(['name' => 'permission', 'folder' => 'system']);
     $node_role = \Solunes\Master\App\Node::create(['name' => 'role', 'folder' => 'system']);
     $node_permission_role = \Solunes\Master\App\Node::create(['name' => 'permission-role', 'table_name' => 'permission_role', 'location' => 'package', 'type' => 'field', 'model' => '\\Solunes\\Master\\App\\Permission', 'parent_id' => $node_role->id]);
     $node_user = \Solunes\Master\App\Node::create(['name' => 'user', 'location' => 'app', 'folder' => 'global']);
     \Solunes\Master\App\Filter::create(['node_id' => $node_user->id, 'parameter' => 'status']);
     $node_role_user = \Solunes\Master\App\Node::create(['name' => 'role-user', 'table_name' => 'role_user', 'location' => 'package', 'type' => 'field', 'model' => '\\Solunes\\Master\\App\\Role', 'parent_id' => $node_user->id]);
     $node_email = \Solunes\Master\App\Node::create(['name' => 'email', 'folder' => 'global']);
     $node_activity = \Solunes\Master\App\Node::create(['name' => 'activity', 'table_name' => 'activities', 'folder' => 'system']);
     $node_notification = \Solunes\Master\App\Node::create(['name' => 'notification', 'folder' => 'system']);
     $node_inbox = \Solunes\Master\App\Node::create(['name' => 'inbox', 'table_name' => 'inbox', 'folder' => 'system']);
     $node_inbox_users = \Solunes\Master\App\Node::create(['name' => 'inbox-user', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_inbox->id]);
     $node_inbox_messages = \Solunes\Master\App\Node::create(['name' => 'inbox-message', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_inbox->id]);
     $node_variable = \Solunes\Master\App\Node::create(['name' => 'variable', 'folder' => 'global']);
     $node_image_folder = \Solunes\Master\App\Node::create(['name' => 'image-folder', 'folder' => 'system']);
     $node_image_size = \Solunes\Master\App\Node::create(['name' => 'image-size', 'type' => 'subchild', 'location' => 'package', 'parent_id' => $node_image_folder->id]);
     $node_temp_file = \Solunes\Master\App\Node::create(['name' => 'temp-file', 'folder' => 'system']);
     // Usuarios
     $admin = \Solunes\Master\App\Role::create(['name' => 'admin', 'display_name' => 'Admin']);
     $member = \Solunes\Master\App\Role::create(['name' => 'member', 'display_name' => 'Miembro']);
     $system_perm = \Solunes\Master\App\Permission::create(['name' => 'system', 'display_name' => 'Sistema']);
     $global_perm = \Solunes\Master\App\Permission::create(['name' => 'global', 'display_name' => 'Global']);
     $site_perm = \Solunes\Master\App\Permission::create(['name' => 'site', 'display_name' => 'Site']);
     $form_perm = \Solunes\Master\App\Permission::create(['name' => 'form', 'display_name' => 'Formulario']);
     $dashboard_perm = \Solunes\Master\App\Permission::create(['name' => 'dashboard', 'display_name' => 'Dashboard']);
     $admin->permission_role()->sync([$global_perm->id, $site_perm->id, $form_perm->id, $dashboard_perm->id]);
     // Tamaños de archivos
     \Solunes\Master\App\Variable::create(['name' => 'image_size', 'type' => 'string', 'es' => ['value' => '5']]);
     \Solunes\Master\App\Variable::create(['name' => 'file_size', 'type' => 'string', 'es' => ['value' => '10']]);
     \Solunes\Master\App\Variable::create(['name' => 'image_extension', 'type' => 'string', 'es' => ['value' => 'jpg,jpeg,png,gif']]);
     \Solunes\Master\App\Variable::create(['name' => 'file_extension', 'type' => 'string', 'es' => ['value' => 'doc,docx,xls,xlsx,ppt,pptx,pdf,txt,jpg,jpeg,png,gif']]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \Solunes\Master\App\ImageSize::truncate();
     \Solunes\Master\App\ImageFolder::truncate();
     \Solunes\Master\App\TempFile::truncate();
     \Solunes\Master\App\VariableTranslation::truncate();
     \Solunes\Master\App\Variable::truncate();
     \Solunes\Master\App\InboxUser::truncate();
     \Solunes\Master\App\InboxMessage::truncate();
     \Solunes\Master\App\Inbox::truncate();
     \Solunes\Master\App\Notification::truncate();
     \Solunes\Master\App\Activity::truncate();
     DB::table('permission_role')->truncate();
     DB::table('role_user')->truncate();
     \Solunes\Master\App\Role::truncate();
     \Solunes\Master\App\Permission::truncate();
     \App\User::truncate();
     \Solunes\Master\App\EmailTranslation::truncate();
     \Solunes\Master\App\Email::truncate();
     \Solunes\Master\App\IndicatorValue::truncate();
     \Solunes\Master\App\IndicatorGraph::truncate();
     \Solunes\Master\App\IndicatorAlert::truncate();
     \Solunes\Master\App\Indicator::truncate();
     \Solunes\Master\App\FieldOptionTranslation::truncate();
     \Solunes\Master\App\FieldOption::truncate();
     \Solunes\Master\App\FieldConditional::truncate();
     \Solunes\Master\App\FieldExtra::truncate();
     \Solunes\Master\App\FieldTranslation::truncate();
     \Solunes\Master\App\Field::truncate();
     \Solunes\Master\App\Section::truncate();
     \Solunes\Master\App\Filter::truncate();
     \Solunes\Master\App\NodeExtra::truncate();
     \Solunes\Master\App\NodeRequest::truncate();
     \Solunes\Master\App\NodeTranslation::truncate();
     \Solunes\Master\App\Node::truncate();
     \Solunes\Master\App\MenuTranslation::truncate();
     \Solunes\Master\App\Menu::truncate();
     \Solunes\Master\App\PageTranslation::truncate();
     \Solunes\Master\App\Page::truncate();
     \Solunes\Master\App\SiteTranslation::truncate();
     \Solunes\Master\App\Site::truncate();
     \Solunes\Master\App\Language::truncate();
     \App\PasswordReminder::truncate();
 }
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure                  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (auth()->check() && auth()->user()->isSuperAdmin()) {
         $user_permissions = \Solunes\Master\App\Permission::lists('name');
     } else {
         if (auth()->check()) {
             $user_permissions = auth()->user()->getPermission();
         } else {
             $user_permissions = [];
         }
     }
     if ($request->segment(1) == 'auth') {
         Menu::make('main', function ($menu) {
             $login = $menu->add('Ingresar', 'auth/login');
             $login->prepend('<span class="title"><i class="fa fa-user"></i>');
             $login->append('</span>');
         });
     } else {
         $menu_options = \Solunes\Master\App\Menu::where('site_id', 1)->menuQuery('admin', 1)->get();
         Menu::make('main', function ($menu) use($request, $menu_options, $user_permissions) {
             foreach ($menu_options as $menu_option) {
                 if (!$menu_option->permission || auth()->check() && $user_permissions->contains($menu_option->permission)) {
                     $first_level = $menu->add($menu_option->name, $menu_option->real_link);
                     $first_level->prepend('<span class="title">');
                     if ($menu_option->icon) {
                         $first_level->prepend('<i class="fa fa-' . $menu_option->icon . '"></i>');
                     }
                     $first_level->append('</span>');
                     if (count($menu_option->children) > 0) {
                         $first_level->append('<span class="arrow"></span>');
                         $first_level->attribute(['class' => 'nav-link nav-toggle']);
                         foreach ($menu_option->children as $menu_children) {
                             if (!$menu_children->permission || auth()->check() && $user_permissions->contains($menu_children->permission)) {
                                 $second_level = $first_level->add($menu_children->name, $menu_children->real_link);
                                 if ($menu_children->icon) {
                                     $second_level->prepend('<i class="fa fa-' . $menu_children->icon . '"></i>');
                                 }
                                 if (count($menu_children->children) > 0) {
                                     $second_level->append('<span class="arrow"></span>');
                                     $second_level->attribute(['class' => 'nav-link nav-toggle']);
                                     foreach ($menu_children->children as $menu_children2) {
                                         $third_level = $second_level->add($menu_children2->name, $menu_children2->real_link);
                                         $third_level->attribute(['class' => 'nav-link']);
                                         if ($menu_children2->icon) {
                                             $third_level->prepend('<i class="fa fa-' . $menu_children2->icon . '"></i>');
                                         }
                                     }
                                 } else {
                                     $second_level->attribute(['class' => 'nav-link']);
                                 }
                             }
                         }
                     } else {
                         $first_level->attribute(['class' => 'nav-link']);
                     }
                 }
             }
         });
     }
     return $next($request);
 }