chore: add env variables for filament panel management
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
@@ -10,7 +12,7 @@ use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable, TwoFactorAuthenticatable, MustVerifyEmail, HasRoles;
|
||||
@@ -61,4 +63,9 @@ class User extends Authenticatable
|
||||
->map(fn ($word) => Str::substr($word, 0, 1))
|
||||
->implode('');
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return $this->hasPermissionTo('manage panels');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,14 +28,11 @@ class DashPanelProvider extends PanelProvider
|
||||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
$panel = $panel
|
||||
->default()
|
||||
->id('dash')
|
||||
->path('dash')
|
||||
->login()
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
->path(config('filament-php.route'))
|
||||
->colors(config('filament-php.colors'))
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
->pages([
|
||||
@@ -81,5 +78,19 @@ class DashPanelProvider extends PanelProvider
|
||||
}),
|
||||
])
|
||||
->routes(fn () => FilamentMails::routes());
|
||||
|
||||
if (config('filament-php.enable_login')) {
|
||||
$panel->login();
|
||||
}
|
||||
|
||||
if (config('filament-php.enable_registration')) {
|
||||
$panel->register();
|
||||
}
|
||||
|
||||
if (config('filament-php.enable_profile')) {
|
||||
$panel->profile();
|
||||
}
|
||||
|
||||
return $panel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user