mirror of
https://github.com/nihonbuzz/nihonbuzz-academy.git
synced 2026-01-27 02:41:58 +07:00
48 lines
1.0 KiB
PHP
48 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
use App\Models\Role;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
use Carbon\Carbon;
|
|
|
|
class RoleSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Reset cached roles and permissions
|
|
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
|
|
|
$roles = [
|
|
'super_admin',
|
|
'admin',
|
|
'editor',
|
|
'treasurer',
|
|
'teacher',
|
|
'student',
|
|
'class_leader',
|
|
'alumni',
|
|
];
|
|
|
|
$now = Carbon::now();
|
|
|
|
foreach ($roles as $roleName) {
|
|
$role = Role::where('name', $roleName)->where('guard_name', 'web')->first();
|
|
if (!$role) {
|
|
Role::create([
|
|
'name' => $roleName,
|
|
'guard_name' => 'web',
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|