<?php
namespace Database\Seeders;

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

class AddViewMyFolderInfoPermissionSeeder extends Seeder
{
    public function run()
    {
        // Create the permission if it doesn't exist
        $permission = Permission::firstOrCreate([
            'name' => 'View My Folder Info',
            'guard_name' => 'web',
        ]);

        // Assign to Admin and User roles (adjust as needed)
        $roles = ['Admin', 'User'];
        foreach ($roles as $roleName) {
            $role = Role::where('name', $roleName)->first();
            if ($role) {
                $role->givePermissionTo($permission);
            }
        }
    }
}
