AdminController @ addPermission

This commit is contained in:
2018-12-06 23:14:27 -06:00
parent 446a4b649e
commit 41a6b8aea9

View File

@@ -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.');
}
}