<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;

class RolesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        app()['cache']->forget('spatie.permission.cache');

        Permission::create(['name'=>'mensajes-recibir', 'guard_name' => 'web']);
        Permission::create(['name'=>'admin-configuraciones', 'guard_name' => 'web']);
        Permission::create(['name'=>'admin-usuarios', 'guard_name' => 'web']);
        Permission::create(['name'=>'admin-menu', 'guard_name' => 'web']);
        Permission::create(['name'=>'gestion', 'guard_name' => 'web']);

        $role = Role::create([
            'name'=>'Administrador',
            'guard_name' => 'web',
        ]);
        $role2 = Role::create([
            'name'=>'Gestor',
            'guard_name' => 'web',
        ]);

        $role->givePermissionTo(['admin-usuarios','admin-menu','gestion','admin-configuraciones']);
        $role2->givePermissionTo(['gestion','mensajes-recibir']);
    }
}
