lahan dan tanaman inspeksi update
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user