Update Status kelengkapan data

This commit is contained in:
2026-11-04 17:31:22 +07:00
parent 89c5a1371a
commit 8ef4ae1f15
18 changed files with 245 additions and 53 deletions
+9 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models\Pertanian;
use App\Models\Concerns\KembalikanStatusPetaniKeDraf;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Profile;
@@ -17,7 +18,7 @@ use App\Enums\KeparahanSerangan;
class Tanaman extends Model
{
use SoftDeletes;
use SoftDeletes, KembalikanStatusPetaniKeDraf;
protected $table = 'map_tanaman';
@@ -80,4 +81,11 @@ class Tanaman extends Model
{
return $this->belongsTo(Lahan::class, 'lahan_id');
}
// Untuk trait KembalikanStatusPetaniKeDraf: petani diambil dari lahannya.
protected function petaniIdUntukStatus(): ?int
{
return $this->petani_id ?? self::ingatPerRequest('status_petani.lahan', $this->lahan_id,
fn () => Lahan::withoutGlobalScopes()->whereKey($this->lahan_id)->value('petani_id'));
}
}