<?php

namespace Database\Seeders;

use App\Models\Setting;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;

class PermissionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $adminUser = User::factory()->create([
            'name' => 'Easttown',
            'email' => 'info@easttown.az',
            'password' => Hash::make('easttown123456'),
        ]);

        $developerUser = User::factory()->create([
            'name' => 'Nurlan',
            'email' => 'nnovruzov606@gmail.com',
            'password' => Hash::make('Nurlan055'),
        ]);

        $developerRole = Role::create(['name' => 'developer']);

        // Assign a Developer role to the user
        $developerUser->assignRole($developerRole);
        $adminUser->assignRole($developerRole);

        $permissions = [
            'show dashboard',

            'view roles',
            'create role',
            'store role',
            'edit role',
            'update role',
            'destroy role',

            'view teams',
            'create team',
            'store team',
            'edit team',
            'update team',
            'destroy team',

            'view menuCategories',
            'create menuCategory',
            'store menuCategory',
            'edit menuCategory',
            'update menuCategory',
            'destroy menuCategory',
            
            'view roomCategories',
            'create roomCategory',
            'store roomCategory',
            'edit roomCategory',
            'update roomCategory',
            'destroy roomCategory',

            'view menyus',
            'create menyu',
            'store menyu',
            'edit menyu',
            'update menyu',
            'destroy menyu',

            'view rooms',
            'create room',
            'store room',
            'edit room',
            'update room',
            'destroy room',

            'view projects',
            'create project',
            'store project',
            'edit project',
            'update project',
            'destroy project',

            'view words',
            'create word',
            'store word',
            'edit word',
            'update word',
            'destroy word',


            'view galleries',
            'create gallery',
            'store gallery',
            'edit gallery',
            'update gallery',
            'destroy gallery',

            'view categories',
            'create category',
            'store category',
            'edit category',
            'update category',
            'destroy category',

            'view cooperatives',
            'create cooperative',
            'store cooperative',
            'edit cooperative',
            'update cooperative',
            'destroy cooperative',

            'view offers',
            'create offer',
            'store offer',
            'edit offer',
            'update offer',
            'destroy offer',

            'view partners',
            'create partner',
            'store partner',
            'edit partner',
            'update partner',
            'destroy partner',

            'view contacts',
            'create contact',
            'store contact',
            'edit contact',
            'update contact',
            'destroy contact',

            'view services',
            'create service',
            'store service',
            'edit service',
            'update service',
            'destroy service',

            'view users',
            'create user',
            'store user',
            'edit user',
            'update user',
            'destroy user',
            'impersonate user',

            'edit settings',
            'update settings',


        ];

        foreach ($permissions as $permission) {
            Permission::create(['name' => $permission]);
            $developerRole->givePermissionTo($permission);
        }
    }
}
