Add models and migrations for Anggota, Buku, Kategori, and Peminjaman
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('anggotas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama');
|
||||
$table->string('email')->unique();
|
||||
$table->string('no_telepon', 15)->nullable();
|
||||
$table->text('alamat')->nullable();
|
||||
$table->date('tanggal_bergabung');
|
||||
$table->enum('status', ['aktif', 'nonaktif'])->default('aktif');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('anggotas');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('kategoris', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama_kategori');
|
||||
$table->text('deskripsi')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('kategoris');
|
||||
}
|
||||
};
|
||||
32
database/migrations/2026_03_17_121408_create_bukus_table.php
Normal file
32
database/migrations/2026_03_17_121408_create_bukus_table.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bukus', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('kategori_id')->constrained('kategoris')->onDelete('cascade');
|
||||
$table->string('judul');
|
||||
$table->string('pengarang');
|
||||
$table->string('penerbit');
|
||||
$table->year('tahun_terbit');
|
||||
$table->string('isbn', 20)->unique();
|
||||
$table->integer('stok')->default(0);
|
||||
$table->integer('stok_tersedia')->default(0);
|
||||
$table->text('sinopsis')->nullable();
|
||||
$table->string('cover')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bukus');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('peminjamans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('anggota_id')->constrained('anggotas')->onDelete('cascade');
|
||||
$table->foreignId('buku_id')->constrained('bukus')->onDelete('cascade');
|
||||
$table->date('tanggal_pinjam');
|
||||
$table->date('tanggal_kembali_rencana');
|
||||
$table->date('tanggal_kembali_aktual')->nullable();
|
||||
$table->enum('status', ['dipinjam', 'dikembalikan', 'terlambat'])->default('dipinjam');
|
||||
$table->integer('denda')->default(0);
|
||||
$table->text('catatan')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('peminjamans');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user