From 50296d5c98162aff0a9439a13973495f329ad593 Mon Sep 17 00:00:00 2001 From: AndikaHilmiHamdani Date: Fri, 18 Mar 2022 19:52:58 +0700 Subject: [PATCH] user seeder --- database/seeders/ModelhasRoleSeeder.php | 24 ------------------------ database/seeders/UserSeeder.php | 22 ++++++++++++++++++++-- 2 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 database/seeders/ModelhasRoleSeeder.php diff --git a/database/seeders/ModelhasRoleSeeder.php b/database/seeders/ModelhasRoleSeeder.php deleted file mode 100644 index 851bb73..0000000 --- a/database/seeders/ModelhasRoleSeeder.php +++ /dev/null @@ -1,24 +0,0 @@ -insert([ - 'role_id'=>'2', - 'model_type'=>'App\Models\User', - 'model_id'=>'3', - ]); - } -} diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index c1ccb79..4cbd09a 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\User; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; @@ -16,12 +17,29 @@ class UserSeeder extends Seeder */ public function run() { - DB::table('users')->insert([ - 'nama_karyawan'=>'Kasir2', + $kasir= User::create([ + 'nama_karyawan'=>'kasir 1', 'email'=>'kasir1@rejiku.com', 'alamat'=> 'jalanin aja dulu', 'no_hp'=>'12344', 'password'=>Hash::make('12345678'), ]); + $kasir ->assignRole('kasir'); + $manajer= User::create([ + 'nama_karyawan'=>'Manajer', + 'alamat'=> 'jalanin doang ga jadian', + 'no_hp'=>'12344', + 'email'=>'manajer2@rejiku.com', + 'password'=>bcrypt('12345678') + ]); + $manajer ->assignRole('manajer'); + $kasir= User::create([ + 'nama_karyawan'=>'Kasir 2', + 'alamat'=> 'jalan yok', + 'no_hp'=>'12344', + 'email'=>'kasir2@rejiku.com', + 'password'=>bcrypt('12345678') + ]); + $kasir ->assignRole('kasir'); } }