Esempio n. 1
0
 public function adminSubmit(User $user, Request $request)
 {
     $h = implode(',', Role::latest()->lists('id')->toArray());
     $this->validate($request, ['role' => "required|in:{$h}"]);
     $input = $request->except('_token');
     $role = $input['role'];
     $roleObject = Role::find($role);
     if (!$user->is($role)) {
         if ($roleObject->slug == 'user' || $roleObject->slug == 'legal') {
             if (!$user->is('user') && !$user->is('legal')) {
                 $user->attachRole($role);
             }
         } else {
             $user->attachRole($role);
         }
     }
     return redirect()->back();
 }