Skip to content

Commit

Permalink
allow filament access with superadmin role
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin committed Dec 11, 2022
1 parent 544f8ac commit b5d69b7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Notifications\PasswordResetQueuedNotification;
use App\Notifications\UpdateEmailNotification;
use App\Notifications\VerifyEmailQueuedNotification;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
Expand All @@ -16,7 +17,7 @@
use Spatie\Permission\Traits\HasRoles;
use Vinkla\Hashids\Facades\Hashids;

class User extends Authenticatable implements MustVerifyEmail
class User extends Authenticatable implements MustVerifyEmail, FilamentUser
{
use HasFactory;
use Notifiable;
Expand Down Expand Up @@ -120,4 +121,9 @@ public function scopeCheck(string $ability)
$appCheck = $this->appCan($ability);
return ($sanctumCheck && $appCheck);
}

public function canAccessFilament(): bool
{
return $this->hasRole('superadmin');
}
}

0 comments on commit b5d69b7

Please sign in to comment.