public function postSaveaccessmenu(Request $req)
 {
     data_menu_user::where('id_level', $req->id_level)->delete();
     foreach ($req->id_menu as $id) {
         data_menu_user::create(['id_menu' => $id, 'id_level' => $req->id_level]);
     }
     return redirect()->back()->withNotif(['label' => 'success', 'err' => 'Menu berhasil diperbaharui']);
 }
 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();
     }
 }
Exemple #3
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];
 }