petani booted skor

This commit is contained in:
2026-07-29 16:52:51 +07:00
parent 20e1eee6ff
commit 24a8016710
+3 -3
View File
@@ -94,15 +94,15 @@ class Petani extends Model
protected static function booted(): void protected static function booted(): void
{ {
static::saved(function (Petani $petani) { static::saved(function (Petani $petani) {
$skor = SkorPetani::where('petani_id', $petani->id)->orderBy('id')->first();
$skor = SkorPetani::where('petani_id')->orderBy('id')->first();
if (!$skor) { if (!$skor) {
$petaniUid = $petani->uid; $petaniUid = $petani->uid;
$part = explode('-', $petaniUid); $part = explode('-', $petaniUid);
$skor = SkorPetani::create([ $skor = SkorPetani::create([
'petani_id' => $petani->id,
'uid' => 'SKR-' . $part[1] . '-' . strtoupper(Str::random(10)), 'uid' => 'SKR-' . $part[1] . '-' . strtoupper(Str::random(10)),
'created_by' => $petani->created_by, 'created_by' => $petani->created_by,
'updated_by' => $petani->updated_by, 'updated_by' => $petani->updated_by
]); ]);
} }
}); });