<?php

namespace Database\Seeders;

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

class PermissionSeeder extends Seeder
{
    public function run(): void
    {
        // Assign all existing permissions to admin users
        $admins = User::where('role', 'admin')->get();
        foreach ($admins as $admin) {
            foreach (Permission::all() as $permission) {
                $admin->permissions()->attach($permission->id, ['actions' => json_encode($permission->actions)]);
            }
        }
    }
}
