Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/EntitlementObserver.php
Show All 13 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 void | * @return bool|null | ||||
machniak: I think that maybe we should throw exceptions instead of returning false here. | |||||
Done Inline ActionsReturning false will prohibit the "transaction" from succeeding / being committed. vanmeeuwen: Returning false will prohibit the "transaction" from succeeding / being committed. | |||||
*/ | */ | ||||
public function creating(Entitlement $entitlement) | public function creating(Entitlement $entitlement) | ||||
{ | { | ||||
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 20 Lines • Show All 42 Lines • Show Last 20 Lines |
I think that maybe we should throw exceptions instead of returning false here.