Initial commit: Struktur aplikasi ilycats

This commit is contained in:
Dwi F Sukmana
2026-02-08 15:16:35 +07:00
commit 0921901aed
235 changed files with 29016 additions and 0 deletions
@@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,27 @@
<?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('categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('keywords')->nullable(); // Untuk smart categorization
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('categories');
}
};
@@ -0,0 +1,41 @@
<?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('cats', function (Blueprint $table) {
$table->id();
$table->string('nama_kucing');
$table->string('ras')->nullable();
$table->enum('jenis_kelamin', ['Jantan', 'Betina']);
$table->date('tanggal_lahir')->nullable();
$table->string('foto')->nullable();
$table->decimal('berat_terakhir', 5, 2)->default(0);
$table->string('lokasi')->nullable();
$table->string('pic')->nullable();
$table->text('riwayat_sakit_terakhir')->nullable(); // Menentukan warna card (Sehat/Sakit)
// Jadwal rutin
$table->date('jadwal_vaksin')->nullable();
$table->date('jadwal_obat_cacing')->nullable();
$table->date('jadwal_obat_kutu')->nullable();
$table->date('jadwal_grooming')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cats');
}
};
@@ -0,0 +1,37 @@
<?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('medicines', function (Blueprint $table) {
$table->id();
$table->string('nama_obat');
$table->string('slug')->unique()->nullable();
$table->string('foto_produk')->nullable();
$table->string('kategori')->default('Umum');
$table->foreignId('category_id')->nullable()->constrained('categories')->onDelete('set null');
$table->integer('qty')->default(0);
$table->string('unit')->default('Pcs');
$table->date('expired_date')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('medicines');
}
};
@@ -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
{
// Pastikan ini 'foods' (jamak), bukan 'food'
Schema::create('foods', function (Blueprint $table) {
$table->id();
$table->string('nama_makanan');
$table->string('slug')->unique()->nullable();
$table->integer('qty');
$table->string('unit');
$table->foreignId('category_id')->nullable()->constrained('categories')->onDelete('set null');
$table->string('kategori')->default('Umum');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('foods');
}
};
@@ -0,0 +1,33 @@
<?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('supplies', function (Blueprint $table) {
$table->id();
$table->string('nama_perlengkapan');
$table->string('foto_produk')->nullable();
$table->unsignedBigInteger('category_id')->nullable(); // First occurrence
$table->decimal('qty', 10, 2);
$table->string('unit');
$table->string('kategori')->default('Umum');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('supplies');
}
};
@@ -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('treatments', function (Blueprint $table) {
$table->id();
$table->foreignId('cat_id')->constrained()->onDelete('cascade'); // Relasi ke tabel cats
$table->date('tanggal');
$table->string('keluhan');
$table->string('nama_obat');
$table->string('dosis');
$table->text('keterangan')->nullable();
$table->string('foto_bukti')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('treatments');
}
};
@@ -0,0 +1,31 @@
<?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('weight_histories', function (Blueprint $table) {
$table->id();
$table->foreignId('cat_id')->constrained()->onDelete('cascade'); // Menghubungkan ke tabel cats
$table->date('tanggal_timbang');
$table->decimal('berat', 5, 2); // Contoh: 12.50
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('weight_histories');
}
};
@@ -0,0 +1,63 @@
<?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::table('cats', function (Blueprint $table) {
// Pengecekan sebelum menambah kolom silsilah
if (!Schema::hasColumn('cats', 'induk_jantan_id')) {
$table->foreignId('induk_jantan_id')->nullable()->constrained('cats')->onDelete('set null');
}
if (!Schema::hasColumn('cats', 'induk_betina_id')) {
$table->foreignId('induk_betina_id')->nullable()->constrained('cats')->onDelete('set null');
}
// Pengecekan sebelum menambah kolom lokasi & PIC
if (!Schema::hasColumn('cats', 'lokasi_kandang')) {
$table->string('lokasi_kandang')->nullable();
}
if (!Schema::hasColumn('cats', 'pic_id')) {
$table->foreignId('pic_id')->nullable()->constrained('users')->onDelete('set null');
}
// Pengecekan sebelum menambah jadwal perawatan
if (!Schema::hasColumn('cats', 'jadwal_vaksin')) {
$table->date('jadwal_vaksin')->nullable();
}
if (!Schema::hasColumn('cats', 'jadwal_obat_cacing')) {
$table->date('jadwal_obat_cacing')->nullable();
}
if (!Schema::hasColumn('cats', 'jadwal_obat_kutu')) {
$table->date('jadwal_obat_kutu')->nullable();
}
if (!Schema::hasColumn('cats', 'jadwal_grooming')) {
$table->date('jadwal_grooming')->nullable();
}
// Pengecekan sebelum menambah data fisik
if (!Schema::hasColumn('cats', 'berat_badan')) {
$table->decimal('berat_badan', 5, 2)->nullable();
}
});
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
$table->dropForeign(['induk_jantan_id', 'induk_betina_id', 'pic_id']);
$table->dropColumn([
'induk_jantan_id', 'induk_betina_id', 'lokasi_kandang', 'pic_id',
'jadwal_vaksin', 'jadwal_obat_cacing', 'jadwal_obat_kutu',
'jadwal_grooming', 'berat_badan'
]);
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('treatments', function (Blueprint $table) {
$table->foreignId('medicine_id')->nullable()->constrained('medicines')->onDelete('set null');
$table->integer('qty_used')->default(1);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('treatments', function (Blueprint $table) {
//
});
}
};
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Menambahkan kolom role dan phone untuk mendukung manajemen user & notifikasi WA.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
// Pengecekan aman: hanya tambah jika kolom belum ada
if (!Schema::hasColumn('users', 'role')) {
$table->string('role')->default('user')->after('email'); // admin, user
}
if (!Schema::hasColumn('users', 'phone')) {
$table->string('phone')->nullable()->after('role');
}
});
}
/**
* Reverse the migrations.
* Menghapus kolom yang telah ditambahkan saat rollback.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
// Menghapus kolom jika ingin membatalkan migrasi
$table->dropColumn(['role', 'phone']);
});
}
};
@@ -0,0 +1,30 @@
<?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('activity_logs', function (Blueprint $table) {
$table->id();
// Relasi ke tabel users
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('action'); // CREATED, UPDATED, DELETED
$table->string('model'); // Cat, Medicine, dll
$table->unsignedBigInteger('model_id')->nullable();
$table->text('description'); // Pesan log
$table->json('properties')->nullable(); // Data lama vs baru
$table->string('ip_address', 45)->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('activity_logs');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
if (!Schema::hasTable('settings')) {
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key');
$table->text('value')->nullable();
$table->string('group')->default('general');
$table->timestamps();
});
}
}
public function down(): void
{
Schema::dropIfExists('settings');
}
};
@@ -0,0 +1,27 @@
<?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::table('cats', function (Blueprint $table) {
// Menambahkan kolom deleted_at
$table->softDeletes();
});
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
// Menghapus kolom jika rollback
$table->dropSoftDeletes();
});
}
};
@@ -0,0 +1,37 @@
<?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::table('cats', function (Blueprint $table) {
// Cek jika kolom belum ada, maka buat kolomnya
if (!Schema::hasColumn('cats', 'pic_id')) {
$table->unsignedBigInteger('pic_id')->nullable()->after('lokasi_kandang');
}
// Tambahkan relasi Foreign Key
$table->foreign('pic_id', 'cats_pic_id_rel_unique_foreign') // Beri nama manual yang unik
->references('id')
->on('users')
->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
//
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('treatments', function (Blueprint $table) {
// Menambahkan kolom diagnosa setelah kolom keluhan
$table->text('diagnosa')->after('keluhan');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('treatments', function (Blueprint $table) {
//
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('treatments', function (Blueprint $table) {
// Menambahkan relasi ke tabel users
$table->foreignId('user_id')->nullable()->after('cat_id')->constrained('users')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('treatments', function (Blueprint $table) {
//
});
}
};
@@ -0,0 +1,33 @@
<?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::table('medicines', function (Blueprint $table) {
// 8 digit total, 2 digit di belakang koma (contoh: 999999.99)
$table->decimal('qty', 8, 2)->default(0)->change();
});
Schema::table('treatments', function (Blueprint $table) {
$table->decimal('qty_used', 8, 2)->default(1)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('medicines_and_treatments', function (Blueprint $table) {
//
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
if (!Schema::hasColumn('medicines', 'foto_produk')) {
Schema::table('medicines', function (Blueprint $table) {
$table->string('foto_produk')->nullable()->after('nama_obat');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('medicines', function (Blueprint $table) {
//
});
}
};
@@ -0,0 +1,33 @@
<?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::table('foods', function (Blueprint $table) {
if (!Schema::hasColumn('foods', 'foto_produk')) {
$table->string('foto_produk')->nullable()->after('nama_makanan');
}
if (!Schema::hasColumn('foods', 'kategori')) {
$table->string('kategori')->after('foto_produk')->default('Umum');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('foods', function (Blueprint $table) {
//
});
}
};
@@ -0,0 +1,27 @@
<?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
{
if (!Schema::hasColumn('cats', 'deleted_at')) {
Schema::table('cats', function (Blueprint $table) {
$table->softDeletes();
});
}
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};
@@ -0,0 +1,26 @@
<?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::table('supplies', function (Blueprint $table) {
// Menambahkan kolom slug setelah nama_perlengkapan
$table->string('slug')->unique()->after('nama_perlengkapan')->nullable();
});
}
public function down(): void
{
Schema::table('supplies', function (Blueprint $table) {
$table->dropColumn('slug');
});
}
};
@@ -0,0 +1,24 @@
<?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::table('cats', function (Blueprint $table) {
// Menghapus kolom pic yang menyebabkan konflik
$table->dropColumn('pic');
});
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
// Untuk rollback: tambahkan kembali jika diperlukan
$table->string('pic')->nullable();
});
}
};
@@ -0,0 +1,62 @@
<?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
{
// Tabel Utama Matting
Schema::create('mattings', function (Blueprint $table) {
$table->id();
$table->foreignId('sire_id')->constrained('cats');
$table->foreignId('dam_id')->constrained('cats');
// Pastikan nama kolom menggunakan awalan tgl_ dan akhiran _bapak/_ibu
$table->date('tgl_lahir_sire')->nullable();
$table->date('tgl_lahir_dam')->nullable();
$table->string('no_pedigree_bapak')->nullable(); // FIX
$table->string('no_pedigree_ibu')->nullable(); // FIX
$table->string('ems_bapak')->nullable(); // FIX
$table->string('ems_ibu')->nullable(); // FIX
$table->string('no_microchip_bapak')->nullable(); // FIX
$table->string('no_microchip_ibu')->nullable(); // FIX
$table->date('tgl_kawin_awal');
$table->date('tgl_kawin_akhir');
$table->integer('jumlah_anak_hidup')->default(0);
$table->timestamps();
});
// Tabel Detail Anak (Kittens)
Schema::create('kittens', function (Blueprint $table) {
$table->id();
$table->foreignId('matting_id')->constrained()->onDelete('cascade');
$table->date('tgl_lahir');
$table->string('nama');
$table->enum('jenis_kelamin', ['Jantan', 'Betina']);
$table->string('kode_ems')->nullable();
$table->string('no_microchip')->nullable();
$table->boolean('is_pedigree')->default(false);
$table->string('registry')->nullable(); // ICA, CFA, WCF, FFF
$table->string('foto_ped_1')->nullable();
$table->string('foto_ped_2')->nullable();
$table->string('foto_ped_3')->nullable();
$table->string('foto_ped_4')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('breeding_tables');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('mattings', function (Blueprint $table) {
// 1. Tambahkan tanggal_kawin jika benar-benar belum ada
if (!Schema::hasColumn('mattings', 'tanggal_kawin')) {
$table->date('tanggal_kawin')->nullable()->after('id');
}
// 2. Tambahkan status jika belum ada
if (!Schema::hasColumn('mattings', 'status')) {
$table->string('status')->default('proses')->after('tanggal_kawin');
}
});
}
public function down()
{
Schema::table('mattings', function (Blueprint $table) {
$table->dropColumn(['tanggal_kawin', 'status']);
});
}
};
@@ -0,0 +1,35 @@
<?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
{
// Menambah kolom registry di tabel cats
Schema::table('cats', function (Blueprint $table) {
$table->string('registry')->nullable()->after('ras');
});
// Menambah kolom registry di tabel mattings
Schema::table('mattings', function (Blueprint $table) {
$table->string('registry')->nullable()->after('dam_id');
});
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
$table->dropColumn('registry');
});
Schema::table('mattings', function (Blueprint $table) {
$table->dropColumn('registry');
});
}
};
@@ -0,0 +1,28 @@
<?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::table('kittens', function (Blueprint $table) {
$table->foreignId('cat_id')->nullable()->constrained('cats')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('kittens', function (Blueprint $table) {
//
});
}
};
@@ -0,0 +1,26 @@
<?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::table('cats', function (Blueprint $table) {
// Menambahkan kolom status setelah kolom registry
$table->string('status')->nullable()->default('Active')->after('registry');
});
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
$table->dropColumn('status');
});
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* Mengubah kolom registry agar mendukung penyimpanan data array (Multi-Select)
*/
public function up(): void
{
Schema::table('cats', function (Blueprint $table) {
// Kita gunakan text agar lebih fleksibel dan tidak error saat migrasi
$table->text('registry')->nullable()->change();
});
}
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
$table->string('registry')->nullable()->change();
});
}
};
@@ -0,0 +1,31 @@
<?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::table('cats', function (Blueprint $table) {
// Tambahkan kolom yang dibutuhkan untuk silsilah lengkap
$table->string('pedigree')->nullable()->after('registry');
$table->string('microchip')->nullable()->after('pedigree');
$table->string('kode_ems')->nullable()->after('microchip');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('cats', function (Blueprint $table) {
//
});
}
};
@@ -0,0 +1,28 @@
<?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('roles', function (Blueprint $table) {
$table->id();
$table->string('name'); // Admin, Breeder, dll.
$table->string('slug')->unique(); // admin, breeder
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('roles');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void {
Schema::create('role_permissions', function (Blueprint $table) {
$table->id();
$table->foreignId('role_id')->constrained()->onDelete('cascade');
$table->string('module_slug'); // Contoh: 'cats', 'users', 'finance'
$table->boolean('can_read')->default(0);
$table->boolean('can_create')->default(0);
$table->boolean('can_update')->default(0);
$table->boolean('can_delete')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('role_permissions');
}
};
@@ -0,0 +1,28 @@
<?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::table('users', function (Blueprint $table) {
// Gunakan nullable jika sudah ada data user agar tidak error saat migrasi
$table->foreignId('role_id')->nullable()->after('id')->constrained();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};