updated AuthServiceProvider to utilize Eloquent more fluently.
This commit is contained in:
@@ -33,7 +33,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
$gate->define('isAdmin', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'Admin') {
|
||||
//User has the Admin role
|
||||
return true;
|
||||
@@ -44,7 +44,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
$gate->define('isDirector', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'Director') {
|
||||
//User has the Director role
|
||||
return true;
|
||||
@@ -55,7 +55,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
$gate->define('isUser', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'User') {
|
||||
//User has the User role
|
||||
return true;
|
||||
@@ -66,7 +66,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
$gate->define('isGuest', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'Guest') {
|
||||
//User has the Guest role
|
||||
return true;
|
||||
@@ -77,7 +77,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
$gate->define('isNone', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'None') {
|
||||
//User has no role
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user