Ejemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $authorization = $this->authorizations->find($id);
     $modules = Module::lists('name', 'id');
     $roles = Role::lists('name', 'id');
     $communes = Perimeter::lists('nom_com', 'id');
     $epcis = Perimeter::lists('nom_epci', 'epci');
     $users = User::lists('username', 'id');
     return view('acl::admin.authorizations.edit', compact('authorization', 'modules', 'roles', 'communes', 'epcis', 'users'));
 }
Ejemplo n.º 2
0
 public function handle($request, Closure $next)
 {
     $module = Module::where('slug', '=', $request->segment(1))->firstOrFail();
     if (!is_null(session()->get('auth.' . $module->slug . '.visitor')) && !is_null(session()->get('auth.' . $module->slug . '.contributor'))) {
         $perim = array_merge(session()->get('auth.' . $module->slug . '.visitor'), session()->get('auth.' . $module->slug . '.contributor'));
     } else {
         if (is_null(session()->get('auth.' . $module->slug . '.visitor')) && !is_null(session()->get('auth.' . $module->slug . '.contributor'))) {
             $perim = session()->get('auth.' . $module->slug . '.contributor');
         } else {
             if (!is_null(session()->get('auth.' . $module->slug . '.visitor')) && is_null(session()->get('auth.' . $module->slug . '.contributor'))) {
                 $perim = session()->get('auth.' . $module->slug . '.visitor');
             }
         }
     }
     $perim_id = DB::table('avz_' . $module->id . '_posts')->find($request->id)->perimeter_id;
     if (in_array($perim_id, $perim)) {
         return $next($request);
     } else {
         return new RedirectResponse(url('/' . $module->slug . ''));
     }
 }