You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
704 B
PHTML
32 lines
704 B
PHTML
|
2 months ago
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Seeders;
|
||
|
|
|
||
|
|
use Illuminate\Database\Seeder;
|
||
|
|
use Spatie\Permission\Models\Role;
|
||
|
|
use Spatie\Permission\Models\Permission;
|
||
|
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
|
||
|
|
class RoleSeeder extends Seeder
|
||
|
|
{
|
||
|
|
public function run(): void
|
||
|
|
{
|
||
|
|
// Evita problemas si se vuelve a ejecutar
|
||
|
|
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||
|
|
|
||
|
|
// Roles base
|
||
|
|
$roles = [
|
||
|
|
'usuario',
|
||
|
|
'administrador',
|
||
|
|
'superadmin',
|
||
|
|
];
|
||
|
|
|
||
|
|
foreach ($roles as $role) {
|
||
|
|
Role::firstOrCreate([
|
||
|
|
'name' => $role,
|
||
|
|
'guard_name' => 'web',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|