petani booted skor

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