<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;

class RoleSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $consultant = Role::create(['name' => 'consultant']);

        $consultant->givePermissionTo([
            'view dashboard',
        ]);

        $president = Role::create(['name' => 'president']);

        $president->givePermissionTo([
            'view dashboard',
            'view borrowers',
            'view loans', 'valid loans',
            'view restitutions', 'valid restitutions',
            'view lenders',
            'view credits', 'valid credits',
            'view repayments', 'valid repayments',
            'view treasury',
            'view entries', 'valid entries',
            'view exits', 'valid exits',
            'view boards',
        ]);

        $office_manager = Role::create(['name' => 'office_manager']);

        $office_manager->givePermissionTo([
            'view dashboard',
            'view borrowers', 'store borrowers', 'update borrowers', 'delete borrowers',
            'view loans', 'store loans', 'update loans', 'delete loans',
            'view restitutions', 'store restitutions', 'update restitutions', 'delete restitutions',
            'view treasury',
            'view treasury categories', 'store treasury categories',
            'view entries', 'store entries', 'update entries', 'delete entries',
            'view exits', 'store exits', 'update exits', 'delete exits',
            'view boards', 'store boards', 'update boards', 'delete boards',
        ]);

        $assistant = Role::create(['name' => 'assistant']);

        $assistant->givePermissionTo([
            'view dashboard',
            'view borrowers', 'store borrowers', 'update borrowers', 'delete borrowers',
            'view loans', 'store loans', 'update loans', 'delete loans',
            'view restitutions', 'store restitutions', 'update restitutions', 'delete restitutions',
            'view treasury',
            'view entries', 'store entries', 'update entries', 'delete entries',
            'view exits', 'store exits', 'update exits', 'delete exits',
            'view boards', 'store boards', 'update boards', 'delete boards',
        ]);
    }
}
