- Created SubClassificationPolicy to manage authorization for SubClassification actions. - Created SubLocationPolicy to manage authorization for SubLocation actions. - Created UserPolicy to manage authorization for User actions. - Integrate Filament Shield for role and permission management - Updated DashboardPanelProvider to include FilamentShieldPlugin. - Added filament-shield package to composer.json and updated composer.lock. - Created filament-shield.php configuration file for Shield settings. - Created permission.php configuration file for Spatie permissions. - Added migration for creating permission tables. - Created ShieldSeeder to seed roles and permissions. - Updated DatabaseSeeder to include ShieldSeeder. - Updated UserSeeder to assign the Developer role to the created user.
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
use App\Enums\IsActive;
|
|
use Filament\Models\Contracts\FilamentUser;
|
|
use Filament\Panel;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
class User extends Authenticatable implements FilamentUser
|
|
{
|
|
use HasRoles, Notifiable, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'password' => 'hashed',
|
|
'is_active' => IsActive::class,
|
|
];
|
|
}
|
|
|
|
public function canAccessPanel(Panel $panel): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
#[Scope]
|
|
protected function withoutDeveloper(Builder $query): void
|
|
{
|
|
$query->whereDoesntHave('roles', function ($q) {
|
|
$q->where('name', 'Developer');
|
|
});
|
|
}
|
|
}
|