lahan dan tanaman inspeksi update

This commit is contained in:
2026-04-21 13:59:01 +07:00
parent 224d8754c8
commit cd0b755f46
5 changed files with 189 additions and 19 deletions
+1 -17
View File
@@ -27,10 +27,7 @@ class Panen extends Model
'notes',
'sync_status',
];
/**
* Casting tipe data agar konsisten saat diakses di Frontend/JSON.
*/
protected $casts = [
'weight_kg' => 'float',
'harvest_date' => 'date:Y-m-d',
@@ -40,29 +37,16 @@ class Panen extends Model
'updated_at' => 'datetime',
];
/**
* Relasi ke Lahan (Many-to-One)
*/
public function lahan(): BelongsTo
{
return $this->belongsTo(Lahan::class, 'land_id');
}
/**
* Relasi ke Tanaman (Many-to-One)
*/
public function tanaman(): BelongsTo
{
// Pastikan nama model Tanaman sudah sesuai (misal: Tanaman atau Plant)
return $this->belongsTo(Tanaman::class, 'plant_id');
}
/**
* Relasi ke Profile Petani (Many-to-One)
*/
public function petani(): BelongsTo
{
// farmer_id merujuk ke tabel profiles (profile_id)
return $this->belongsTo(\App\Models\Profile::class, 'farmer_id');
}
}