/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { //检测是否登录,未登录跳转,登录了赋予菜单 if (\Session::has('adminlogin')) { if (!env('PERMISSION_USE_CACHE', 'true')) { $uinfo = \Pianke\Models\AdminUser::find(\Session::get('adminlogin')->id); \Session::put('adminlogin', $uinfo); \Pianke\Models\AdminPermission::getCurPermissionArray(explode("|", $uinfo->role->permissions)); } view()->share('menu', \Session::get('menu')); } else { return redirect()->action('\\Pianke\\Http\\Controllers\\AdminLoginController@getLogin'); } //检测是否有权限访问操作 if (!in_array('\\' . \Route::currentRouteAction(), \Session::get('curpermissions'))) { return redirect()->back()->withNotice(['type' => 'error', 'msg' => trans('admin.nopermission'), 'title' => trans('admin.permissionerror')]); } return $next($request); }
public function getUserstatus() { $id = \Request::input('id'); $s = \Request::input('s') == '1' ? 0 : 1; $uinfo = \Pianke\Models\AdminUser::find($id); if ($uinfo and $id != \Session::get('adminlogin')->id) { $uinfo->status = $s; if ($uinfo->save()) { return redirect()->action('\\Pianke\\Http\\Controllers\\AdminManagerController@getUserlist')->withNotice(['type' => 'success', 'msg' => '', 'title' => trans('admin.actsuccess')]); } else { return redirect()->action('\\Pianke\\Http\\Controllers\\AdminManagerController@getUserlist')->withNotice(['type' => 'error', 'msg' => trans('admin.acterror'), 'title' => trans('admin.actfailed')]); } } else { return redirect()->action('\\Pianke\\Http\\Controllers\\AdminManagerController@getUserlist')->withNotice(['type' => 'warning', 'msg' => trans('admin.notunactiveself'), 'title' => trans('admin.actfailed')]); } }