Anons79 Mini Shell

Directory : /home/aplikasiposinfo/.trash/database/seeders/
Upload File :
Current File : /home/aplikasiposinfo/.trash/database/seeders/UsersSeeder.php

<?php

namespace Database\Seeders;

use App\Models\Role;
use App\Models\User;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;

class UsersSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {   
        $menus = [
            'role'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'perusahaan'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'user'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'lokasi absen'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'jadwal kerja'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'karyawan'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'absensi'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'permintaan absensi'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'kunjungan'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'timesheet'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'reimbursement category'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'reimbursement'=>[
                'lihat',
                'tambah',
                'ubah',
                'hapus'
            ],
            'laporan'=>[
                'lihat',
                'export',
            ]
        ];
        $user = User::updateOrCreate([
            'email' => '[email protected]',
        ],[
            'nama' => 'Master Admin',
            'password' => bcrypt('password')
        ]);
        $role = Role::firstOrCreate([
            'name'=>'admin',
        ]);

        $permissions = [];
        foreach ($menus ?? [] as $menu => $aksi) {
            foreach ($aksi as $a) {
                $permissions[] = Permission::firstOrCreate(['name'=>$a." ".$menu]);
            }
        }
        if(count($permissions) > 0){
            $role->syncPermissions($permissions);
        }

        $user->syncRoles([$role]);
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]