updated permissions

This commit is contained in:
Edward Tirado Jr 2025-12-30 21:15:42 -06:00
parent 8f47f40b03
commit 83f7073b18
31 changed files with 1467 additions and 901 deletions

View file

@ -5,9 +5,12 @@ namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Context;
use Illuminate\Support\Str;
use Laravel\Fortify\TwoFactorAuthenticatable;
@ -44,6 +47,19 @@ class User extends Authenticatable
return $this->hasOne(UserProfile::class);
}
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class);
}
public function hasRole(string $role): bool
{
if (Context::hasHidden('roles')) {
return in_array(strtolower($role), Context::getHidden('roles'));
}
return $this->roles->contains('name', strtolower($role));
}
/**
* Get the user's initials
*/