Пример #1
0
 public function getEdit($id = 0)
 {
     if (empty($id)) {
         return redirect()->back();
     }
     $menu = data_menu::whereStatus(1)->whereParent_id(0)->get();
     $edit = data_menu::find($id);
     return view('Menus.show', ['parent' => $menu, 'menu' => $edit]);
 }
Пример #2
0
 public function handle()
 {
     $data = json_decode($this->req['update']);
     $seri = 1;
     foreach ($data as $menus) {
         $menu = data_menu::find($menus->id);
         $menu->parent_id = 0;
         $menu->seri = $seri;
         $menu->save();
         $seri++;
         $seri1 = 1;
         if (!empty($menus->children)) {
             foreach ($menus->children as $child) {
                 $menu = data_menu::find($child->id);
                 $menu->parent_id = $menus->id;
                 $menu->seri = $seri1;
                 $menu->save();
                 $seri1++;
                 // Children 2
                 $seri2 = 1;
                 if (!empty($child->children)) {
                     foreach ($child->children as $child2) {
                         $menu = data_menu::find($child2->id);
                         $menu->parent_id = $child->id;
                         $menu->seri = $seri2;
                         $menu->save();
                         $seri2++;
                         // Children 3
                         $seri3 = 1;
                         if (!empty($child2->children)) {
                             foreach ($child2->children as $child3) {
                                 $menu = data_menu::find($child3->id);
                                 $menu->parent_id = $child2->id;
                                 $menu->seri = $seri3;
                                 $menu->save();
                                 $seri3++;
                                 // Children 4
                                 $seri4 = 1;
                                 if (!empty($child3->children)) {
                                     foreach ($child3->children as $child4) {
                                         $menu = data_menu::find($child4->id);
                                         $menu->parent_id = $child3->id;
                                         $menu->seri = $seri4;
                                         $menu->save();
                                         $seri3++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 public function handle()
 {
     if (!empty($this->req['del'])) {
         $id_menu = $this->req['id_menu'];
         $menu = data_menu::find($id_menu);
         $menu->delete();
         data_menu_user::whereId_menu($id_menu)->delete();
     } else {
         $menu = data_menu::find($this->req['id_menu']);
         $menu->title = $this->req['title'];
         $menu->parent_id = $this->req['idparent'];
         $menu->slug = $this->req['slug'];
         $menu->class = $this->req['class'];
         $menu->status = $this->req['status'];
         $menu->class_id = $this->req['id'];
         $menu->ket = $this->req['ket'];
         $menu->save();
     }
 }
Пример #4
0
 public function handle()
 {
     return data_menu::create(['parent_id' => $this->req['idparent'], 'title' => $this->req['title'], 'slug' => $this->req['slug'], 'class' => $this->req['class'], 'class_id' => $this->req['id'], 'seri' => 0, 'ket' => $this->req['ket'], 'status' => $this->req['status']]);
 }
Пример #5
0
 public function access()
 {
     $paths = '';
     for ($i = 0; $i < 2; $i++) {
         if (isset($this->path[$i])) {
             $paths .= $this->path[$i] . '/';
         }
     }
     $path = rtrim($paths, '/');
     $menu = data_menu_user::whereIn('id_level', \Me::level())->get();
     $access = [];
     foreach ($menu as $val) {
         $access[] = $val->id_menu;
     }
     $slug = data_menu::whereIn('id_menu', $access)->select('slug')->get();
     $slugs = [];
     foreach ($slug as $aces) {
         $slugs[] = $aces->slug;
     }
     if (!empty(\Request::path())) {
         $cek = empty($path) ? 0 : data_menu::whereSlug($path)->count();
         if (!empty($path) && !in_array($path, $slugs) && $cek > 0) {
             return ['return' => false];
         }
         $cek = empty($path) ? 0 : data_menu::whereSlug($path)->count();
         if (!empty($path) && !in_array($path, $slugs) && $cek > 0) {
             return ['return' => false];
         }
     }
     return ['return' => true];
 }