Commit c729f4d0 by f3brysan

#8: Penggunaan Traits/UUID ke User Model

parent 83b4f371
......@@ -2,23 +2,18 @@
namespace App\Models;
use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Users extends Model
{
use Uuid;
public $incrementing = false;
protected $table = 'user';
protected $fillable = [
'id',
'nama',
'email',
'password',
'idrole',
'idpegawai',
'created_at',
'updated_at',
protected $guarded = [
'id'
];
public function rRole()
......
......@@ -3,7 +3,11 @@
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Faker\Factory;
use App\Models\Users;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
......@@ -15,10 +19,16 @@ class DatabaseSeeder extends Seeder
public function run()
{
// \App\Models\User::factory(10)->create();
$faker = Factory::create();
// generate data by calling methods
for($i = 1; $i <= 10; $i++){
// insert data ke table pegawai menggunakan Faker
Users::create([
'nama' => $faker->name,
'email' => $faker->email,
'password' => Hash::make('password')
]);
}
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment