Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/WalletObserver.php
Show All 12 Lines | class WalletObserver | ||||
* Ensure the wallet ID is a custom ID (uuid). | * Ensure the wallet ID is a custom ID (uuid). | ||||
* | * | ||||
* @param Wallet $wallet | * @param Wallet $wallet | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function creating(Wallet $wallet) | public function creating(Wallet $wallet) | ||||
{ | { | ||||
while (true) { | |||||
$allegedly_unique = \App\Utils::uuidStr(); | |||||
if (!Wallet::find($allegedly_unique)) { | |||||
$wallet->{$wallet->getKeyName()} = $allegedly_unique; | |||||
break; | |||||
} | |||||
} | |||||
$wallet->currency = \config('app.currency'); | $wallet->currency = \config('app.currency'); | ||||
} | } | ||||
/** | /** | ||||
* Handle the wallet "deleting" event. | * Handle the wallet "deleting" event. | ||||
* | * | ||||
* Ensures that a wallet with a non-zero balance can not be deleted. | * Ensures that a wallet with a non-zero balance can not be deleted. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |