Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     //To delete the table data before creating new ones
     \App\Entities\Menu::truncate();
     \App\Entities\Menu::create(['id' => 1, 'sequence' => '1', 'icon' => 'fa fa-dashboard', 'name' => 'Dashboard', 'link' => '#/dashboard']);
     \App\Entities\Menu::create(['id' => 10, 'sequence' => '2', 'icon' => 'fa fa-calendar', 'name' => 'Agenda', 'link' => '#/agenda']);
     \App\Entities\Menu::create(['id' => 20, 'sequence' => '3', 'icon' => 'fa fa-diamond', 'name' => 'Clientes', 'link' => '#/clientes']);
     \App\Entities\Menu::create(['id' => 30, 'sequence' => '4', 'icon' => 'fa fa-truck', 'name' => 'Fornecedores', 'link' => '#/fornecedores']);
     \App\Entities\Menu::create(['id' => 40, 'sequence' => 5, 'icon' => 'si si-folder', 'name' => 'Cadastros']);
     \App\Entities\Menu::create(['id' => 50, 'sequence' => '5', 'name' => 'Banco', 'parent_id' => 40, 'link' => '#/banco']);
     \App\Entities\Menu::create(['id' => 51, 'sequence' => '6', 'name' => 'Unidade de Medida', 'parent_id' => 40, 'link' => '#/unidademedida']);
     \App\Entities\Menu::create(['id' => 52, 'sequence' => '6', 'name' => 'Template Orçamento', 'parent_id' => 40, 'link' => '#/templateorcamento']);
     \App\Entities\Menu::create(['id' => 5, 'sequence' => '6', 'name' => 'Sistema', 'parent_id' => 40, 'link' => '#/servico']);
     \App\Entities\Menu::create(['id' => 60, 'sequence' => '6', 'name' => 'Material', 'parent_id' => 40, 'link' => '#/material']);
     \App\Entities\Menu::create(['id' => 70, 'sequence' => '7', 'name' => 'Ramo de Atividade', 'parent_id' => 40, 'link' => '#/ramoatividade']);
     \App\Entities\Menu::create(['id' => 78, 'sequence' => 5, 'icon' => 'fa fa-building', 'name' => 'Empresa']);
     \App\Entities\Menu::create(['id' => 79, 'sequence' => '1', 'name' => 'Abertura de ano', 'parent_id' => 78, 'link' => '#/ano']);
     \App\Entities\Menu::create(['id' => 80, 'sequence' => '8', 'icon' => 'fa fa-lock', 'name' => 'Admin', 'link' => '#/admin']);
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
Ejemplo n.º 2
0
 public function get()
 {
     $menu = Menu::all();
     if ($menu) {
         foreach ($menu as $objMenu) {
             if (!$objMenu->parent_id) {
                 $itemMenu = ['id' => $objMenu->id, 'parent_id' => $objMenu->parent_id, 'sequence' => $objMenu->sequence, 'icon' => $objMenu->icon, 'name' => $objMenu->name, 'link' => $objMenu->link, 'active' => $objMenu->active];
                 $arrayMenu[$objMenu->id] = $itemMenu;
                 $allowedPrincipal[] = $objMenu->id;
             }
         }
     }
     //Submenu
     foreach ($menu as $objMenu) {
         if ($objMenu->parent_id && in_array($objMenu->parent_id, $allowedPrincipal)) {
             $itemMenu = ['id' => $objMenu->id, 'parent_id' => $objMenu->parent_id, 'sequence' => $objMenu->sequence, 'icon' => $objMenu->icon, 'name' => $objMenu->name, 'link' => $objMenu->link, 'active' => $objMenu->active];
             $arrayMenu[$objMenu->parent_id]["submenu"][] = $itemMenu;
         }
     }
     return $arrayMenu;
 }