Update Status kelengkapan data
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user