<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class PermissionsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('permissions')->insert([
            [
                'name' => 'admins',
                'display_name' => 'Admins',
                'parent' => 0,
                'guard_name' => 'admin'
            ],[
                'name' => 'role_&_permission',
                'display_name' => 'Role & Permission',
                'parent' => 0,
                'guard_name' => 'admin'
            ],[
                'name' => 'create',
                'display_name' => 'Create',
                'parent' => 1,
                'guard_name' => 'admin'
            ],[
                'name' => 'update',
                'display_name' => 'Update',
                'parent' => 1,
                'guard_name' => 'admin'
            ],[
                'name' => 'delete',
                'display_name' => 'Delete',
                'parent' => 1,
                'guard_name' => 'admin'
            ],[
                'name' => 'roles',
                'display_name' => 'Roles',
                'parent' => 2,
                'guard_name' => 'admin'
            ],[
                'name' => 'permissions',
                'display_name' => 'Permissions',
                'parent' => 2,
                'guard_name' => 'admin'
            ]
        ]);

        DB::table('roles')->insert([
            [
                'name' => 'Super-Admin',
                'guard_name' => 'admin'
            ]
        ]);

        DB::table('role_has_permissions')->insert([
            [
                'permission_id' => 1,
                'role_id' => 1
            ],[
                'permission_id' => 2,
                'role_id' => 1
            ],[
                'permission_id' => 3,
                'role_id' => 1
            ],[
                'permission_id' => 4,
                'role_id' => 1
            ],[
                'permission_id' => 5,
                'role_id' => 1
            ],[
                'permission_id' => 6,
                'role_id' => 1
            ],[
                'permission_id' => 7,
                'role_id' => 1
            ]
        ]);

        DB::table('model_has_roles')->insert([
            [
                'role_id' => 1,
                'model_type' => 'App\Models\Admin',
                'model_id' => 1
            ]
        ]);
    }
}
