Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/EntitlementObserver.php
Show All 14 Lines | class EntitlementObserver | ||||
* | * | ||||
* Ensures that the entry uses a custom ID (uuid). | * Ensures that the entry uses a custom ID (uuid). | ||||
* | * | ||||
* Ensures that the {@link \App\Wallet} to which it is to be billed is owned or controlled by | * Ensures that the {@link \App\Wallet} to which it is to be billed is owned or controlled by | ||||
* the {@link \App\User} entitled. | * the {@link \App\User} entitled. | ||||
* | * | ||||
* @param Entitlement $entitlement The entitlement being created. | * @param Entitlement $entitlement The entitlement being created. | ||||
* | * | ||||
* @return bool|null | * @return bool | ||||
*/ | */ | ||||
public function creating(Entitlement $entitlement) | public function creating(Entitlement $entitlement): bool | ||||
{ | { | ||||
while (true) { | while (true) { | ||||
$allegedly_unique = \App\Utils::uuidStr(); | $allegedly_unique = \App\Utils::uuidStr(); | ||||
if (!Entitlement::find($allegedly_unique)) { | if (!Entitlement::find($allegedly_unique)) { | ||||
$entitlement->{$entitlement->getKeyName()} = $allegedly_unique; | $entitlement->{$entitlement->getKeyName()} = $allegedly_unique; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
Show All 13 Lines | public function creating(Entitlement $entitlement): bool | ||||
return false; | return false; | ||||
} | } | ||||
$result = $sku->handler_class::preReq($entitlement, $wallet->owner); | $result = $sku->handler_class::preReq($entitlement, $wallet->owner); | ||||
if (!$result) { | if (!$result) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | |||||
} | } | ||||
/** | |||||
* Handle the entitlement "created" event. | |||||
* | |||||
* @param \App\Entitlement $entitlement The entitlement. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function created(Entitlement $entitlement) | public function created(Entitlement $entitlement) | ||||
{ | { | ||||
$entitlement->entitleable->updated_at = Carbon::now(); | $entitlement->entitleable->updated_at = Carbon::now(); | ||||
$entitlement->entitleable->save(); | $entitlement->entitleable->save(); | ||||
} | } | ||||
/** | /** | ||||
* Handle the entitlement "deleted" event. | * Handle the entitlement "deleted" event. | ||||
Show All 18 Lines |