base commit

This commit is contained in:
Mekan1206
2026-07-30 17:24:40 +05:00
commit a794dacd39
345 changed files with 29597 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Database\Seeders;
use App\Models\User;
use BezhanSalleh\FilamentShield\Support\Utils;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
class RoleSeeder extends Seeder
{
/**
* @var list<string>
*/
private const ROLES = [
'administrator',
'hr_manager',
'supervisor',
'department_manager',
'viewer',
];
public function run(): void
{
Utils::createRole();
$guardName = $this->guardName();
foreach (self::ROLES as $roleName) {
Role::firstOrCreate([
'name' => $roleName,
'guard_name' => $guardName,
]);
}
$admin = User::query()->where('email', 'admin@company.com')->first();
if ($admin !== null) {
$admin->assignRole(Utils::getSuperAdminName());
}
}
private function guardName(): string
{
$guard = Utils::getFilamentAuthGuard();
return $guard !== '' ? $guard : (string) config('auth.defaults.guard', 'web');
}
}