diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 1e4ee62f3..0112f772a 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -26,9 +26,9 @@ class AdminController extends Controller //Get the character id from the username using the user table $character = DB::table('users')->where('name', $user)->first(); //Check to see if the character already has the permission - $check = DB::table('user_permissions')->where(['character_id' => $character->character_id, 'permission' => $permission])->get(); + $check = DB::table('user_permissions')->where(['character_id' => $character->character_id, 'permission' => $permission])->get(['permission']); //If the user doesn't have the permission then add it into the table - if($check == null) { + if(!isset($check[0]->permission)) { $perm = new UserPermission; $perm->character_id = $character->character_id; $perm->permission = $permission; @@ -36,7 +36,7 @@ class AdminController extends Controller return view('admin.dashboard')->with('success', 'User udpated!'); } else { - return view('admin.dashboard')->with('error', 'User not updated.'); + return view('admin.dashboard')->with('error', 'User not updated or already has the permission.'); } }