<?php

namespace Modules\Dummy\Database\Seeders\Core\Versions\V2_9_0;

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

class PermissionsTableSeeder extends Seeder
{
    public function run()
    {
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@index')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@index',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController',
                'controller_name' => 'StaffController',
                'method_name' => 'index',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@create')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@create',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController',
                'controller_name' => 'StaffController',
                'method_name' => 'create',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@store')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@store',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController',
                'controller_name' => 'StaffController',
                'method_name' => 'store',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@edit')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@edit',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController',
                'controller_name' => 'StaffController',
                'method_name' => 'edit',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@update')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@update',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController',
                'controller_name' => 'StaffController',
                'method_name' => 'update',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@destroy')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController@destroy',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Staff\\StaffController',
                'controller_name' => 'StaffController',
                'method_name' => 'destroy',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@index')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@index',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController',
                'controller_name' => 'RoleController',
                'method_name' => 'index',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@create')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@create',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController',
                'controller_name' => 'RoleController',
                'method_name' => 'create',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@store')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@store',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController',
                'controller_name' => 'RoleController',
                'method_name' => 'store',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@edit')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@edit',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController',
                'controller_name' => 'RoleController',
                'method_name' => 'edit',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@update')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@update',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController',
                'controller_name' => 'RoleController',
                'method_name' => 'update',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@destroy')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController@destroy',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\Roles\\RoleController',
                'controller_name' => 'RoleController',
                'method_name' => 'destroy',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\PermissionController@generate')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\PermissionController@generate',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\PermissionController',
                'controller_name' => 'PermissionController',
                'method_name' => 'generate',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\PermissionController@index')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\PermissionController@index',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\PermissionController',
                'controller_name' => 'PermissionController',
                'method_name' => 'index',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
        if (! Permission::where('name', 'App\\Http\\Controllers\\Vendor\\PermissionController@assign')->first()) {

            $permissionId = Permission::insertGetId([
                'name' => 'App\\Http\\Controllers\\Vendor\\PermissionController@assign',
                'controller_path' => 'App\\Http\\Controllers\\Vendor\\PermissionController',
                'controller_name' => 'PermissionController',
                'method_name' => 'assign',
            ]);
            PermissionRole::insert([
                'permission_id' => $permissionId,
                'role_id' => 2,
            ]);
        }
    }
}
