/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $data['role'] = Role::find($id);
     $data['modules'] = Module::all();
     //dd($data['role']->roleDetails->where('id_module',137)->first()->module->name);
     return view('admin.role_details.index', compact('data'));
 }
Beispiel #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //install modules by loading controllers into modules table
     $controllersDirContent = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('../app/Http/Controllers'), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($controllersDirContent as $key => $val) {
         if (!preg_match('#\\\\.{0,2}$#', $key) && preg_match('#\\.php$#', $key)) {
             $name = explode('Controllers\\', $key)[1];
             if (Module::where('name', $name)->first() === null) {
                 Module::create(["name" => $name]);
             }
         }
     }
     $roles = Role::all();
     return view('admin.roles.index', compact('roles'));
 }
Beispiel #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $actions = array();
     //Get the controller and the action from the route
     $controller = explode("@", $request->route()->getActionName());
     $controllerName = explode('Controllers\\', $controller[0])[1] . ".php";
     $controllerAction = $controller[1];
     //find module with the same name of the controller
     $module = Module::where('name', $controllerName)->first();
     //Get the role detail for the corresponing user role and module
     $roleDetail = RoleDetail::where('id_role', $this->auth->user()->role->id)->where('id_module', $module->id)->first();
     //Check if action is allowed according to roleDetails mod_show, mod_insert, mod_update, mod_delete
     $this->checkAction($controllerAction, $roleDetail, $request);
     return $next($request);
 }