Error correction and preparation of the project for initial deployment
This commit is contained in:
@@ -8,7 +8,6 @@ use App\Containers\InstituteStructure\Models\Faculty;
|
||||
use App\Ship\Contracts\SeoDescriptionInterface;
|
||||
use App\Ship\Contracts\SeoTitleInterface;
|
||||
use App\Ship\Traits\HasSeo;
|
||||
use BezhanSalleh\FilamentShield\FilamentShield;
|
||||
use BezhanSalleh\FilamentShield\Support\Utils;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
@@ -97,19 +96,7 @@ class User extends Authenticatable implements FilamentUser, SeoTitleInterface, S
|
||||
return $this->hasOne(AcceptedInvitation::class, 'receiver_id');
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
if (config('filament-shield.dashboard_user.enabled', false)) {
|
||||
FilamentShield::createRole(name: config('filament-shield.dashboard_user.name', 'dashboard_user'));
|
||||
FilamentShield::createRole(name: config('', 'editor'));
|
||||
static::created(function (User $user) {
|
||||
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
|
||||
});
|
||||
static::deleting(function (User $user) {
|
||||
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel|\Filament\Panel $panel): bool
|
||||
{
|
||||
return match ($panel->getId()) {
|
||||
|
||||
@@ -20,6 +20,9 @@ class UserObserver
|
||||
public function created(User $user): void
|
||||
{
|
||||
$this->userCacheService->clearAllCacheByModel();
|
||||
if (\Illuminate\Support\Facades\Schema::hasTable('roles')) {
|
||||
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,4 +59,4 @@ class UserObserver
|
||||
$this->userCacheService->clearCache($user);
|
||||
$this->userCacheService->clearAllCacheByModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ship\Commands;
|
||||
use BezhanSalleh\FilamentShield\FilamentShield;
|
||||
|
||||
|
||||
use App\Ship\Abstracts\Commands\ConsoleCommand as AbstractConsoleCommand;
|
||||
|
||||
class InitRoles extends AbstractConsoleCommand
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'roles:init-roles';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Initializes default roles for Filament Shield.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
// Проверяем, что Filament Shield включен
|
||||
if (!config('filament-shield.dashboard_user.enabled', false)) {
|
||||
$this->warn('Filament Shield dashboard user is not enabled in the config.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Создаем роли
|
||||
FilamentShield::createRole(
|
||||
name: config('filament-shield.dashboard_user.name', 'dashboard_user')
|
||||
);
|
||||
FilamentShield::createRole(
|
||||
name: config('', 'editor')
|
||||
);
|
||||
|
||||
$this->info('Filament Shield roles have been initialized successfully.');
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Ship\Kernels;
|
||||
|
||||
use AlxDorosenco\PortoForLaravel\Loaders\CommandsLoader;
|
||||
use AlxDorosenco\PortoForLaravel\Loaders\RoutesLoader;
|
||||
use App\Ship\Commands\InitRoles;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as LaravelConsoleKernel;
|
||||
|
||||
@@ -23,6 +24,10 @@ class ConsoleKernel extends LaravelConsoleKernel
|
||||
$schedule->command('sitemap:generate')->dailyAt('03:00');
|
||||
}
|
||||
|
||||
protected $commands = [
|
||||
InitRoles::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user