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