Page MenuHomePhorge

DiscountObserver.php
No OneTemporary

DiscountObserver.php

<?php
namespace App\Observers;
use App\Discount;
/**
* This is an observer for the Discount model definition.
*/
class DiscountObserver
{
/**
* Ensure the discount ID is a custom ID (uuid).
*
* @param \App\Discount $discount The discount object
*
* @return void
*/
public function creating(Discount $discount): void
{
while (true) {
$allegedly_unique = \App\Utils::uuidStr();
if (!Discount::find($allegedly_unique)) {
$discount->{$discount->getKeyName()} = $allegedly_unique;
break;
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 11, 10:33 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
325908
Default Alt Text
DiscountObserver.php (626 B)

Event Timeline