diff --git a/app/Models/Distribusi/Distribution.php b/app/Models/Distribusi/Distribution.php index b2b727b..f280c76 100644 --- a/app/Models/Distribusi/Distribution.php +++ b/app/Models/Distribusi/Distribution.php @@ -14,17 +14,17 @@ class Distribution extends Model // Karena id adalah BIGINT auto-increment, default Laravel sudah benar (incrementing = true) protected $fillable = [ - 'farmer_id', 'farmer_name', 'offtaker_id', 'offtaker_name', - 'commodity_name', 'quantity_kg', 'farmer_grade', 'offtaker_grade', - 'grade_difference_reason', 'price_per_kg', 'total_value', - 'distribution_date', 'received_date', 'notes', 'status', - 'sync_status', 'created_date', 'updated_date' + 'petani_id','panen_uid', 'nama_pengirim', 'offtaker_id', 'nama_offtaker', + 'komoditas_id', 'berat_kg', 'grade_petani', 'grade_offtaker', + 'alasan_perbedaan_grade', 'harga_per_kg', 'total', + 'tgl_distribusi', 'tgl_terima', 'catatan', 'status', + 'sync_status', 'created_date', 'updated_date', ]; protected $casts = [ - 'quantity_kg' => 'float', - 'price_per_kg' => 'float', - 'total_value' => 'float', + 'berat_kg' => 'float', + 'harga_per_kg' => 'float', + 'total' => 'float', 'created_date' => 'datetime', 'updated_date' => 'datetime', ]; diff --git a/app/Models/Map/InsLahan.php b/app/Models/Map/InsLahan.php index a615958..c672167 100644 --- a/app/Models/Map/InsLahan.php +++ b/app/Models/Map/InsLahan.php @@ -9,12 +9,13 @@ class InsLahan extends Model { use HasFactory; - protected $table = 'inspeksi_lahan'; + protected $table = 'lahan_inspeksi'; protected $fillable = [ 'petani_id', 'lahan_id', 'kadar_air', + 'lahan_uid', 'ph', 'kelembapan', 'temperatur', @@ -22,6 +23,7 @@ class InsLahan extends Model 'catatan', 'foto_url', 'sync_status', + 'tgl_inspeksi', 'created_at', 'updated_at' ]; @@ -30,6 +32,7 @@ class InsLahan extends Model 'temperatur' => 'float', 'kelembapan' => 'float', 'created_at' => 'datetime', + 'tgl_inspeksi' => 'datetime' ]; public $timestamps = true; diff --git a/app/Models/Map/Inspeksi.php b/app/Models/Map/Inspeksi.php index e310385..d6f35f3 100644 --- a/app/Models/Map/Inspeksi.php +++ b/app/Models/Map/Inspeksi.php @@ -15,13 +15,14 @@ class Inspeksi extends Model{ "tanaman_id", "lahan_id", "petani_id", - "inspection_date", - "health_status", - "productivity_status", - "issue_type", - "issue_description", - "recommendation", - "notes", + "tanaman_uid", + "tgl_inspeksi", + "status_tanaman", // sehat, sakit + "produktifitas", // produktif, kurang dan tidak + "masalah", // hama, kurang air dll + "deskripsi", + "tindakan", // tindakan apa yang disarankan + "catatan", "created_date", "sync_status" ]; diff --git a/app/Models/Map/Lahan.php b/app/Models/Map/Lahan.php index f0dcc6c..671c45c 100644 --- a/app/Models/Map/Lahan.php +++ b/app/Models/Map/Lahan.php @@ -36,4 +36,9 @@ class Lahan extends Model { return $this->hasMany(Tanaman::class, 'lahan_id'); } + + public function panens(): HasMany + { + return $this->hasMany(Panen::class, 'lahan_id'); + } } diff --git a/app/Models/Map/Panen.php b/app/Models/Map/Panen.php index 8061b2a..bd2a962 100644 --- a/app/Models/Map/Panen.php +++ b/app/Models/Map/Panen.php @@ -22,12 +22,12 @@ class Panen extends Model protected $fillable = [ 'uid', // PN-1234567890-1234567890-1234567890 (lahan-tanaman-panen) // 'plant_id', - 'title', - 'land_id', - 'farmer_id', - 'land_description', - 'harvest_date', - 'notes', + 'judul', + 'lahan_id', + 'petani_id', + 'deskripsi', + 'tgl_panen', + 'catatan', 'sync_status', 'created_by', 'updated_by', diff --git a/app/Models/Map/PanenTanaman.php b/app/Models/Map/PanenTanaman.php index b735a70..44f7c6e 100644 --- a/app/Models/Map/PanenTanaman.php +++ b/app/Models/Map/PanenTanaman.php @@ -13,9 +13,9 @@ class PanenTanaman extends Model protected $fillable = [ "panen_id", "tanaman_id", - "commodity_name", + "komoditas_id", "sync_status", - "weight_kg" + "berat_kg" ]; public function panen(): BelongsTo diff --git a/app/Models/Map/Tanaman.php b/app/Models/Map/Tanaman.php index 484cfab..72ec626 100644 --- a/app/Models/Map/Tanaman.php +++ b/app/Models/Map/Tanaman.php @@ -16,6 +16,8 @@ class Tanaman extends Model 'komoditas_id', 'profile_id', 'lahan_id', + 'uid', // TN-1234567890-1234567890-1234567890 (lahan-tanaman-panen) + 'komoditas_kode', 'latitude', 'longitude', 'kondisi_tanaman', @@ -33,7 +35,7 @@ class Tanaman extends Model public function komoditas() { - return $this->belongsTo(Komoditas::class, 'komoditas_id'); + return $this->belongsTo(\App\Models\Pertanian\Komoditas::class, 'komoditas_id'); } public function panen() diff --git a/database/migrations/2026_04_27_092223_create_panen_table.php b/database/migrations/2026_04_27_092223_create_panen_table.php index 70b346c..29c8e1d 100644 --- a/database/migrations/2026_04_27_092223_create_panen_table.php +++ b/database/migrations/2026_04_27_092223_create_panen_table.php @@ -10,11 +10,11 @@ return new class extends Migration { $table->id(); $table->string('uid')->unique()->nullable(); // Bagus untuk sinkronisasi Dexie offline $table->string('title'); // Judul aktivitas panen - $table->unsignedBigInteger('land_id')->nullable(); - $table->unsignedBigInteger('farmer_id')->nullable(); - $table->text('land_description')->nullable(); // Deskripsi kondisi lahan saat panen - $table->date('harvest_date'); - $table->text('notes')->nullable(); + $table->unsignedBigInteger('lahan_id')->nullable(); + $table->unsignedBigInteger('petani_id')->nullable(); + $table->text('deskripsi')->nullable(); // Deskripsi kondisi lahan saat panen + $table->date('tgl_panen'); + $table->text('catatan')->nullable(); $table->string('sync_status')->default('pending'); // Audit Columns diff --git a/database/migrations/2026_04_27_092225_create_inspection_table.php b/database/migrations/2026_04_27_092225_create_inspection_table.php index 794e60e..9aa73e6 100644 --- a/database/migrations/2026_04_27_092225_create_inspection_table.php +++ b/database/migrations/2026_04_27_092225_create_inspection_table.php @@ -11,13 +11,14 @@ return new class extends Migration { $table->unsignedBigInteger('tanaman_id')->nullable(); $table->unsignedBigInteger('lahan_id')->nullable(); $table->unsignedBigInteger('petani_id')->nullable(); - $table->date('inspection_date')->nullable(); - $table->string('health_status')->nullable(); - $table->string('productivity_status')->nullable(); - $table->string('issue_type')->nullable(); - $table->text('issue_description')->nullable(); - $table->text('recommendation')->nullable(); - $table->text('notes')->nullable(); + $table->string('tanaman_uid'); + $table->date('tgl_inspeksi')->nullable(); + $table->string('status_tanaman')->nullable(); + $table->string('produktifitas')->nullable(); + $table->string('masalah')->nullable(); + $table->text('deskripsi')->nullable(); + $table->text('tindakan')->nullable(); + $table->text('catatan')->nullable(); $table->string('sync_status')->default('pending'); // Audit Columns diff --git a/database/migrations/2026_04_27_092226_create_inslahan_table.php b/database/migrations/2026_04_27_092226_create_inslahan_table.php index ef66514..2979fd4 100644 --- a/database/migrations/2026_04_27_092226_create_inslahan_table.php +++ b/database/migrations/2026_04_27_092226_create_inslahan_table.php @@ -6,15 +6,17 @@ use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up(): void { - Schema::create('inspeksi_lahan', function (Blueprint $table) { + Schema::create('lahan_inspeksi', function (Blueprint $table) { $table->id(); $table->foreignId('petani_id')->nullable()->constrained('users')->onDelete('set null'); $table->unsignedBigInteger('lahan_id')->nullable(); + $table->string('lahan_uid'); $table->double('kadar_air')->nullable(); $table->double('ph')->nullable(); $table->double('kelembapan')->nullable(); $table->double('temperatur')->nullable(); $table->string('kondisi_tanaman')->nullable(); + $table->date('tgl_inspeksi'); $table->text('catatan')->nullable(); $table->string('foto_url')->nullable(); $table->string('sync_status')->default('pending'); diff --git a/database/migrations/2026_05_18_145106_add_kode_to_table_komoditas.php b/database/migrations/2026_05_18_145106_add_kode_to_table_komoditas.php new file mode 100644 index 0000000..7213b66 --- /dev/null +++ b/database/migrations/2026_05_18_145106_add_kode_to_table_komoditas.php @@ -0,0 +1,29 @@ +string('kode')->unique(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('master_komoditas', function (Blueprint $table) { + $table->dropUnique('kode'); + $table->dropColumn('kode'); + }); + } +}; diff --git a/database/migrations/2026_05_20_104305_create_table_panen_commodity.php b/database/migrations/2026_05_20_104305_create_table_panen_commodity.php new file mode 100644 index 0000000..331d8b9 --- /dev/null +++ b/database/migrations/2026_05_20_104305_create_table_panen_commodity.php @@ -0,0 +1,36 @@ +id(); + $table->string('uid')->unique()->nullable(); + $table->foreignId('panen_id')->constrained('map_panen')->onDelete('cascade'); + + $table->unsignedBigInteger('plant_id')->nullable(); // ID Tanaman (tanaman_id) + $table->integer('komoditas_id'); // Nama komoditas + $table->double('weight_kg')->default(0); // Berat hasil panen (panen_kg) + $table->string('sync_status')->default('pending'); + + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('panen_komoditas'); + } +}; diff --git a/database/migrations/2026_06_06_134032_create_panen_tanamen_table.php b/database/migrations/2026_06_06_134032_create_panen_tanamen_table.php index e55dfdd..3cc15e2 100644 --- a/database/migrations/2026_06_06_134032_create_panen_tanamen_table.php +++ b/database/migrations/2026_06_06_134032_create_panen_tanamen_table.php @@ -19,9 +19,9 @@ return new class extends Migration ->onDelete('cascade'); $bluePrint->unsignedBigInteger('tanaman_id')->nullable(); - $bluePrint->string('commodity_name'); + $bluePrint->string('komoditas_id'); $bluePrint->string('sync_status', 50)->nullable()->default('synced'); - $bluePrint->decimal('weight_kg', 10, 2); // Menggunakan decimal agar mendukung angka pecahan (misal: 10.5 kg) + $bluePrint->decimal('berat_kg', 10, 2); // Menggunakan decimal agar mendukung angka pecahan (misal: 10.5 kg) $bluePrint->timestamps(); $bluePrint->softDeletes(); // Menambahkan kolom deleted_at untuk fitur SoftDeletes