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
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -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) {
//
});
}
};
+70
View File
@@ -0,0 +1,70 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Cat;
use App\Models\User;
use Illuminate\Support\Carbon;
class CatSeeder extends Seeder
{
public function run(): void
{
$user = User::first() ?? User::create([
'name' => 'Staff Cattery',
'email' => 'staff@earrincats.com',
'password' => bcrypt('password'),
'role' => 'admin'
]);
$cats = [
[
'nama_kucing' => 'Kenzo',
'ras' => 'Persian',
'jenis_kelamin' => 'Jantan',
'tanggal_lahir' => Carbon::parse('2023-01-15'),
'lokasi_kandang' => 'A1', // FIX: Hapus akhiran 'an'
'pic_id' => $user->id,
'berat_badan' => 5.2,
'riwayat_sakit_terakhir' => 'Sehat',
],
[
'nama_kucing' => 'Mochi',
'ras' => 'Persian',
'jenis_kelamin' => 'Betina',
'tanggal_lahir' => Carbon::parse('2023-03-10'),
'lokasi_kandang' => 'A2', // FIX: Hapus akhiran 'an'
'pic_id' => $user->id,
'berat_badan' => 4.1,
'riwayat_sakit_terakhir' => 'Sehat',
],
[
'nama_kucing' => 'Bruno',
'ras' => 'British Shorthair',
'jenis_kelamin' => 'Jantan',
'tanggal_lahir' => Carbon::parse('2022-11-20'),
'lokasi_kandang' => 'B1', // FIX: Hapus akhiran 'an'
'pic_id' => $user->id,
'berat_badan' => 6.5,
'riwayat_sakit_terakhir' => 'Flu Ringan',
],
[
'nama_kucing' => 'Luna',
'ras' => 'British Shorthair',
'jenis_kelamin' => 'Betina',
'tanggal_lahir' => Carbon::parse('2023-05-05'),
'lokasi_kandang' => 'B2', // FIX: Hapus akhiran 'an'
'pic_id' => $user->id,
'berat_badan' => 3.8,
'riwayat_sakit_terakhir' => 'Sembuh',
],
];
foreach ($cats as $cat) {
Cat::create($cat);
}
$this->command->info('Data dummy kucing berhasil diperbarui dan dibuat!');
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class CategorySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$data = [
['name' => 'Antibiotik', 'keywords' => 'amoxicillin, clavamox, doxycycline, antibiotic'],
['name' => 'Antiparasit', 'keywords' => 'worm, cacing, flea, kutu, revolution, drontal'],
['name' => 'Vitamin', 'keywords' => 'stimuno, nutriplus, fish oil, minyak ikan, calcium'],
['name' => 'Vaksin', 'keywords' => 'tricat, felocell, rabies, purevax'],
['name' => 'Flu & Batuk', 'keywords' => 'flu, batuk, contracold, iliadin'],
];
foreach ($data as $item) {
\App\Models\Category::updateOrCreate(['name' => $item['name']], $item);
}
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call([
CatSeeder::class,
InventorySeeder::class,
TreatmentSeeder::class,
]);
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Database\Seeders;
use App\Models\Medicine;
use App\Models\Food;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class InventorySeeder extends Seeder
{
public function run(): void
{
// 1. Data Obat
// Pastikan Model Medicine juga memiliki logic slug yang sama dengan Food
Medicine::create([
'nama_obat' => 'Iliadin Drop',
'slug' => Str::slug('Iliadin Drop') . '-' . Str::random(5),
'kategori' => 'Flu & Pilek',
'qty' => 3,
'unit' => 'Botol',
'expired_date' => '2026-12-01',
]);
Medicine::create([
'nama_obat' => 'Vet-Otic',
'slug' => Str::slug('Vet-Otic') . '-' . Str::random(5),
'kategori' => 'Obat Telinga',
'qty' => 10,
'unit' => 'Pcs',
]);
// 2. Data Makanan
// Logika saving di Model Food akan tetap berjalan sebagai pengaman ganda
Food::create([
'nama_makanan' => 'Royal Canin Mother & Baby',
'slug' => Str::slug('Royal Canin Mother & Baby') . '-' . Str::random(5),
'qty' => 2,
'unit' => 'Zak',
]);
Food::create([
'nama_makanan' => 'Equilibrio Kitten',
'slug' => Str::slug('Equilibrio Kitten') . '-' . Str::random(5),
'qty' => 15,
'unit' => 'Kg',
]);
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Cat;
use App\Models\Matting;
use App\Models\Kitten;
use Illuminate\Support\Carbon;
class MattingSeeder extends Seeder
{
public function run(): void
{
// Ambil data kucing untuk indukan
$sires = Cat::where('jenis_kelamin', 'Jantan')->get();
$dams = Cat::where('jenis_kelamin', 'Betina')->get();
if ($sires->isEmpty() || $dams->isEmpty()) {
$this->command->warn("Data kucing jantan/betina belum ada. Jalankan CatSeeder dulu!");
return;
}
// SCENARIO 1: Breeding Baru (Countdown Indigo)
// Estimasi lahir masih sekitar 50 hari lagi
Matting::create([
'sire_id' => $sires->first()->id,
'dam_id' => $dams->first()->id,
'ems_bapak' => 'BSH a',
'ems_ibu' => 'BSH a',
'tgl_kawin_awal' => Carbon::now()->subDays(10),
'tgl_kawin_akhir' => Carbon::now()->subDays(7),
'jumlah_anak_hidup' => 0,
]);
// SCENARIO 2: Breeding Urgent (Countdown Merah + Pulse)
// Sisa 3 hari lagi menuju HPL (H+63)
Matting::create([
'sire_id' => $sires->last()->id,
'dam_id' => $dams->last()->id,
'ems_bapak' => 'PER n 03',
'ems_ibu' => 'PER f 03',
'tgl_kawin_awal' => Carbon::now()->subDays(60),
'tgl_kawin_akhir' => Carbon::now()->subDays(57),
'jumlah_anak_hidup' => 0,
]);
// SCENARIO 3: Breeding Selesai (Menampilkan Jumlah Anak)
$m3 = Matting::create([
'sire_id' => $sires->random()->id,
'dam_id' => $dams->random()->id,
'ems_bapak' => 'BSH ns 11',
'ems_ibu' => 'BSH ns 11',
'tgl_kawin_awal' => Carbon::now()->subMonths(4),
'tgl_kawin_akhir' => Carbon::now()->subMonths(4)->addDays(3),
'jumlah_anak_hidup' => 3,
]);
// Tambahkan data anak kucing untuk Matting ke-3
for ($i = 1; $i <= 3; $i++) {
Kitten::create([
'matting_id' => $m3->id,
'nama' => 'Earrin ' . ['Shadow', 'Snowy', 'Ginger'][$i-1],
'jenis_kelamin' => $i % 2 == 0 ? 'Betina' : 'Jantan',
'tgl_lahir' => Carbon::now()->subMonths(2),
'kode_ems' => 'BSH ns 11',
]);
}
$this->command->info("Dummy Matting Cattery berhasil dibuat!");
}
}
+74
View File
@@ -0,0 +1,74 @@
<?php
namespace Database\Seeders;
use App\Models\Role;
use App\Models\User;
use App\Models\RolePermission;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\DB;
class RoleAndUserSeeder extends Seeder
{
public function run(): void
{
// 1. Definisikan Modul yang ada di aplikasi ilycats
$modules = [
'cats' => 'Manajemen Kucing',
'matting' => 'Breeding & Matting',
'treatments'=> 'Rekam Medis',
'inventory' => 'Logistik & Stok',
'users' => 'Manajemen User',
'roles' => 'Hak Akses',
'logs' => 'Audit Trail',
'settings' => 'Pengaturan Sistem'
];
DB::transaction(function () use ($modules) {
// 2. Buat Role Admin
$adminRole = Role::updateOrCreate(
['slug' => 'admin'],
['name' => 'Administrator']
);
// Berikan Admin akses FULL ke semua modul
foreach ($modules as $slug => $label) {
RolePermission::updateOrCreate([
'role_id' => $adminRole->id,
'module_slug' => $slug,
], [
'can_read' => 1, 'can_create' => 1, 'can_update' => 1, 'can_delete' => 1
]);
}
// 3. Buat Role Staff
$staffRole = Role::updateOrCreate(
['slug' => 'staff'],
['name' => 'Staff Operasional']
);
// Berikan Staff akses terbatas (Hanya Operasional & Tanpa Delete)
$staffModules = ['cats', 'matting', 'treatments', 'inventory'];
foreach ($staffModules as $slug) {
RolePermission::updateOrCreate([
'role_id' => $staffRole->id,
'module_slug' => $slug,
], [
'can_read' => 1, 'can_create' => 1, 'can_update' => 1, 'can_delete' => 0
]);
}
// 4. Buat User Admin Pertama (Agar bisa login)
User::updateOrCreate(
['email' => 'admin@ilycats.com'],
[
'name' => 'Super Admin',
'password' => Hash::make('password123'), // Silakan ganti nanti
'role_id' => $adminRole->id,
'role' => 'admin', // Menjaga kompatibilitas kode lama Anda
]
);
});
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use App\Models\Supply;
use Illuminate\Database\Seeder;
class SupplySeeder extends Seeder
{
/**
* Jalankan database seeds untuk perlengkapan Ily Cattery.
*/
public function run(): void
{
// HAPUS $this->call dari sini!
$supplies = [
['nama_perlengkapan' => 'Pasir Gumpal Bento 10L Lavender', 'qty' => 15, 'unit' => 'bag'],
['nama_perlengkapan' => 'Kandang Alumunium Besar 3 Pintu', 'qty' => 2, 'unit' => 'unit'],
['nama_perlengkapan' => 'Sisir Grooming Stainless Steel', 'qty' => 5, 'unit' => 'pcs'],
['nama_perlengkapan' => 'Mainan Stick Bulu Interaktif', 'qty' => 12, 'unit' => 'pcs'],
['nama_perlengkapan' => 'Bowl Makan Keramik Anti-Semut', 'qty' => 20, 'unit' => 'pcs'],
['nama_perlengkapan' => 'Pet Cargo Transporter Hitam', 'qty' => 4, 'unit' => 'unit'],
['nama_perlengkapan' => 'Gunting Kuku Kucing Ergonomis', 'qty' => 3, 'unit' => 'pcs'],
['nama_perlengkapan' => 'Handuk Microfiber Khusus Mandi', 'qty' => 10, 'unit' => 'pcs'],
];
foreach ($supplies as $item) {
/**
* Menggunakan Model::create agar event 'saving' di booted() terpanggil.
* Ini penting agar kategori terisi otomatis.
*/
Supply::create($item);
}
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use App\Models\Cat;
use App\Models\Treatment;
use Illuminate\Database\Seeder;
class TreatmentSeeder extends Seeder
{
public function run(): void
{
$milo = Cat::where('nama_kucing', 'Milo')->first();
$oliver = Cat::where('nama_kucing', 'Oliver')->first();
if ($milo) {
Treatment::create([
'cat_id' => $milo->id,
'tanggal' => now()->subDays(2),
'keluhan' => 'Bersin terus menerus',
'nama_obat' => 'Flu-Cat Syrup',
'dosis' => '0.5ml / 2x sehari',
]);
}
if ($oliver) {
Treatment::create([
'cat_id' => $oliver->id,
'tanggal' => now()->subDay(),
'keluhan' => 'Gatal di telinga',
'nama_obat' => 'Salep Scabies',
'dosis' => 'Oles tipis pagi/malam',
]);
}
}
}