<?php

namespace Database\Seeders;

use App\Models\Permission;
use Illuminate\Database\Seeder;

/**
 * RBAC-02 from the system analysis: the permissions table existed with no
 * seeded rows, so the Roles screen's checkboxes had nothing to offer. This
 * is the concrete, granular list every role (seeded or custom) picks from.
 */
class PermissionSeeder extends Seeder
{
    public function run(): void
    {
        foreach ([
            ['name' => 'bookings.manage', 'label' => 'Manage bookings (create, dispatch, cancel)'],
            ['name' => 'drivers.manage', 'label' => 'Manage drivers (onboard, edit, documents)'],
            ['name' => 'vehicles.manage', 'label' => 'Manage vehicles (onboard, edit, documents)'],
            ['name' => 'fare-rules.manage', 'label' => 'Manage vehicle types & fare rules'],
            ['name' => 'customers.manage', 'label' => 'Manage customers'],
            ['name' => 'accounts.manage', 'label' => 'Manage corporate accounts'],
            ['name' => 'payouts.manage', 'label' => 'Manage driver payouts'],
            ['name' => 'users.manage', 'label' => 'Manage staff users'],
            ['name' => 'shifts.manage', 'label' => 'Manage driver shifts (force-end)'],
            ['name' => 'settings.manage', 'label' => 'Manage company settings'],
        ] as $permission) {
            Permission::updateOrCreate(['name' => $permission['name']], $permission);
        }
    }
}
