<?php

namespace Database\Seeders;

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

class PermissionsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {

        $resources = [
            'Dashboard' => [
                'index' => 'Lihat Dashboard',
            ],
            'Pelaporan' => [
                'index' => 'Melihat Daftar Pelaporan',
            ],
            'Verifikasi' => [
                'index' => 'Mengakses Verifikasi Pelaporan',
            ],
            'Hukum' => [
                'index' => 'Melihat Data Penegakan Hukum',
            ],
            'Perizinan' => [
                'index' => 'Melihat Data Perizinan Lingkungan',
            ],
            'History' => [
                'index' => 'Melihat History Perusahaan',
            ],
            'Post' => [
                'index' => 'Mengakses Data Postingan',
            ],
            'Kategori' => [
                'index' => 'Melihat Kategori Post',
            ],
            'SubKategori' => [
                'index' => 'Melihat Sub Kategori Post',
            ],
            'Verifikator' => [
                'index' => 'Mengakses Data Dinas LH / Verifikator',
            ],
            'JenisKegiatan' => [
                'index' => 'Melihat Daftar Jenis Kegiatan',
            ],
            'JenisDokil' => [
                'index' => 'Melihat Daftar Jenis Dokumen Izin',
            ],
            'Perusahaan' => [
                'index' => 'Mengakses Data Perusahaan',
            ],
            'HistoryKegiatan' => [
                'index' => 'Melihat History Kegiatan',
            ],
            'JenisSanksi' => [
                'index' => 'Melihat Jenis Sanksi',
            ],
            'Penaatan' => [
                'index' => 'Melihat Status Penaatan',
            ],
            'Pengguna' => [
                'index' => 'Melihat Daftar Pengguna',
            ],
            'Role' => [
                'index' => 'Melihat Kelompok Pengguna',
            ],
            'Tentang' => [
                'index' => 'Melihat Informasi Tentang Aplikasi',
            ],
            'Catatan' => [
                'index' => 'Melihat Catatan Sistem',
            ],
            'Backup' => [
                'index' => 'Mengakses Fitur Backup Data',
            ],
            'Restore' => [
                'index' => 'Mengakses Fitur Restore Data',
            ],
        ];
        foreach ($resources as $resource => $actions) {
            foreach ($actions as $action => $description) {
                $permissionName = "{$resource}.{$action}";

                Permission::updateOrCreate(
                    ['name' => $permissionName, 'guard_name' => 'web'],
                    ['description' => $description]
                );
            }
        }
        }
    }
