petani booted skor
This commit is contained in:
@@ -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
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user