<?php
/**
 * Permission Seeder Class
 *
 * @version     1.0.0
 * @package     bplan-base/globals
 * @subpackage  Seeders
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Database\Seeders;


use BplanBase\Globals\Models\Permission;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;


/**
 *
 * @version     1.0.0 / 2026-06-07
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class PermissionSeeder extends Seeder
{


/* +++ TRAITS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS CONSTANTS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT MEMBERS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS MEMBERS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT METHODS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * @return      void
     *
     * @version     1.0.0 / 2026-06-07
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function run(): void
    {
        $date      = date('Y-m-d H:i:s');
        $package   = 'globals';
        $guardName = 'web';

        $resources = [
            'countries',
            'entity_type_fields',
            'entity_type_models',
            'entity_types',
            'external_systems',
            'location_types',
            'locations',
            'permissions',
            'printer_types',
            'printers',
            'roles',
            'settings',
            'tenant_external_systems',
            'users',
        ];

        $rows = [];

        foreach ($resources as $resource) {
            foreach (['create', 'delete', 'read', 'update'] as $action) {
                $rows[] = [
                    'uuid'       => Str::uuid(),
                    'created_at' => $date,
                    'updated_at' => $date,
                    'guard_name' => $guardName,
                    'name'       => $resource.'.'.$action,
                    'package'    => $package,
                ];
            }
        }
        Permission::insert($rows);

    } // run()


/* +++ CLASS METHODS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


} // class PermissionSeeder extends Seeder {}
