<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;


class RoleAndPermissionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // Permission::create(['name'=>'create-users']);
        // Permission::create(['name'=>'edit-users']);
        // Permission::create(['name'=>'delete-users']);

        // Permission::create(['name'=>'create-blog']);
        // Permission::create(['name'=>'edit-blog']);
        // Permission::create(['name'=>'delete-blog']);

        // $adminRole=Role::create(['name'=>'Admin']);
        // $editRole=Role::create(['name'=>'Editor']);

        // $adminRole->givePermissionTo([
        //         'create-users',
        //         'edit-users',
        //         'delete-users',
        //         'create-blog',
        //         'edit-blog',
        //         'delete-blog',
        // ]);
        // $editRole->givePermissionTo([
        //         'create-blog',
        //         'edit-blog',
        //         'delete-blog',

        // ]);

                $permissions = [
           'role-list',
           'role-create',
           'role-edit',
           'role-delete',
           'product-list',
           'product-create',
           'product-edit',
           'product-delete'
        ];
     
        foreach ($permissions as $permission) {
             Permission::create(['name' => $permission]);
        }

    }
}
