modifying gates

This commit is contained in:
2018-11-10 14:55:07 -06:00
parent 4efd174c6b
commit 53ab89b133
2 changed files with 4 additions and 7 deletions

View File

@@ -27,10 +27,6 @@ class AuthServiceProvider extends ServiceProvider
{
$this->registerPolicies($gate);
$gate->define('isSuperAdmin', function($user) {
return $user->hasRole('SuperAdmin');
});
$gate->define('isAdmin', function($user) {
return $user->hasRole('Admin');
});

View File

@@ -5,8 +5,8 @@ namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;
use Auth;
class User extends Authenticatable
{
@@ -48,7 +48,8 @@ class User extends Authenticatable
//Used in middleware to make sure a user is able to access many of the pages
public function hasRole($role)
{
$checks = User::roles()->get();
$checks = DB::table('user_roles')->where(['character_id' => auth()->user()->character_id])->get();
//$checks = User::roles()->get();
foreach($checks as $check) {
if($check['role'] == $role) {
return true;