116 lines
3.1 KiB
PHP
116 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use App\Models\User;
|
|
use App\Models\Admin;
|
|
use App\Models\Presensi;
|
|
use App\Models\Cuti;
|
|
use App\Models\Announcement;
|
|
use Carbon\Carbon;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// \App\Models\User::factory(10)->create();
|
|
|
|
// \App\Models\User::factory()->create([
|
|
// 'name' => 'Test User',
|
|
// 'email' => 'test@example.com',
|
|
// ]);
|
|
|
|
$this->call([
|
|
AdminSeeder::class,
|
|
UserSeeder::class,
|
|
// ... seeder lainnya
|
|
]);
|
|
|
|
// Hapus data yang ada terlebih dahulu
|
|
Admin::truncate();
|
|
User::truncate();
|
|
Presensi::truncate();
|
|
Cuti::truncate();
|
|
Announcement::truncate();
|
|
|
|
// Seed Admin
|
|
Admin::create([
|
|
'name' => 'Super Admin',
|
|
'email' => 'admin@example.com',
|
|
'password' => Hash::make('password123'),
|
|
]);
|
|
|
|
// Seed Users (Karyawan)
|
|
$user1 = User::create([
|
|
'name' => 'John Doe',
|
|
'email' => 'john@example.com',
|
|
'password' => Hash::make('password123'),
|
|
'pin_code' => '123456',
|
|
'role' => 'karyawan'
|
|
]);
|
|
|
|
$user2 = User::create([
|
|
'name' => 'Jane Doe',
|
|
'email' => 'jane@example.com',
|
|
'password' => Hash::make('password123'),
|
|
'pin_code' => '234567',
|
|
'role' => 'staff'
|
|
]);
|
|
|
|
// Seed beberapa data presensi
|
|
Presensi::create([
|
|
'user_id' => $user1->id,
|
|
'latitude' => -6.123456,
|
|
'longitude' => 106.123456,
|
|
'status' => 'Hadir',
|
|
'clock_type' => 'in',
|
|
'keterangan' => 'Masuk',
|
|
'foto' => 'foto1.jpg'
|
|
]);
|
|
|
|
Presensi::create([
|
|
'user_id' => $user2->id,
|
|
'latitude' => -6.123456,
|
|
'longitude' => 106.123456,
|
|
'status' => 'Hadir',
|
|
'clock_type' => 'in',
|
|
'keterangan' => 'Masuk',
|
|
'foto' => 'foto2.jpg'
|
|
]);
|
|
|
|
// Seed beberapa data cuti
|
|
Cuti::create([
|
|
'user_id' => $user1->id,
|
|
'nama' => 'John Doe',
|
|
'jenis_cuti' => 'Tahunan',
|
|
'keterangan' => 'Cuti tahunan',
|
|
'tanggal_mulai' => now(),
|
|
'tanggal_selesai' => now()->addDays(3),
|
|
'status' => 'Pending'
|
|
]);
|
|
|
|
Cuti::create([
|
|
'user_id' => $user2->id,
|
|
'nama' => 'Jane Doe',
|
|
'jenis_cuti' => 'Sakit',
|
|
'keterangan' => 'Cuti sakit',
|
|
'tanggal_mulai' => now(),
|
|
'tanggal_selesai' => now()->addDays(2),
|
|
'status' => 'Pending'
|
|
]);
|
|
|
|
// Create sample announcements
|
|
Announcement::create([
|
|
'title' => 'Pengumuman Penting',
|
|
'content' => 'Ini adalah contoh pengumuman untuk testing dashboard.',
|
|
'created_at' => Carbon::now(),
|
|
]);
|
|
}
|
|
}
|