93 lines
2.9 KiB
PHP
93 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Carbon\Carbon;
|
|
|
|
class LibrarySeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
// ====== Data Buku ======
|
|
DB::table('books')->insert([
|
|
[
|
|
'judul' => 'Pemrograman Laravel Dasar',
|
|
'penulis' => 'Ahmad Rizal',
|
|
'penerbit' => 'Informatika',
|
|
'tahun_terbit' => 2022,
|
|
'kategori' => 'Teknologi',
|
|
'jumlah_eksemplar' => 5,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
[
|
|
'judul' => 'Statistik untuk Pemula',
|
|
'penulis' => 'Siti Nurhaliza',
|
|
'penerbit' => 'Gramedia',
|
|
'tahun_terbit' => 2021,
|
|
'kategori' => 'Pendidikan',
|
|
'jumlah_eksemplar' => 3,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
[
|
|
'judul' => 'Manajemen Waktu Efektif',
|
|
'penulis' => 'Dwi Santoso',
|
|
'penerbit' => 'Buku Pintar',
|
|
'tahun_terbit' => 2020,
|
|
'kategori' => 'Motivasi',
|
|
'jumlah_eksemplar' => 2,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
]);
|
|
|
|
// ====== Data Anggota ======
|
|
DB::table('members')->insert([
|
|
[
|
|
'nama' => 'Rina Putri',
|
|
'email' => 'rina@example.com',
|
|
'nomor_anggota' => 'AG001',
|
|
'alamat' => 'Jl. Merdeka No.10, Malang',
|
|
'telepon' => '081234567890',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
[
|
|
'nama' => 'Budi Santoso',
|
|
'email' => 'budi@example.com',
|
|
'nomor_anggota' => 'AG002',
|
|
'alamat' => 'Jl. Mawar No.5, Batu',
|
|
'telepon' => '081298765432',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
]);
|
|
|
|
// ====== Transaksi Peminjaman ======
|
|
DB::table('borrow_transactions')->insert([
|
|
[
|
|
'member_id' => 1,
|
|
'book_id' => 1,
|
|
'tanggal_pinjam' => Carbon::now()->subDays(3),
|
|
'tanggal_kembali' => null,
|
|
'status' => 'dipinjam',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
[
|
|
'member_id' => 2,
|
|
'book_id' => 2,
|
|
'tanggal_pinjam' => Carbon::now()->subDays(10),
|
|
'tanggal_kembali' => Carbon::now()->subDays(2),
|
|
'status' => 'dikembalikan',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
],
|
|
]);
|
|
}
|
|
}
|
|
|