<?php

namespace Database\Seeders;

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

class RoleSeeder extends Seeder {
    public function run(): void {
        $permissions = Permission::all();

        if ($permissions->isEmpty()) {
            $this->command->warn('No permissions found. Run PermissionSeeder first.');
            return;
        }

        $role = Role::updateOrCreate(
            [
                'name' => 'DeepLinx',
                'description' => 'DeepLinx Role for Developer',
                'color' => '#45bb34',
                'guard_name' => 'web',
            ],
        );

        $role->syncPermissions($permissions);
    }
}
