Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/PlanObserver.php
Show All 14 Lines | class PlanObserver | ||||
* Ensures that the entry uses a custom ID (uuid). | * Ensures that the entry uses a custom ID (uuid). | ||||
* | * | ||||
* @param Plan $plan The Plan being created. | * @param Plan $plan The Plan being created. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function creating(Plan $plan) | public function creating(Plan $plan) | ||||
{ | { | ||||
while (true) { | |||||
$allegedly_unique = \App\Utils::uuidStr(); | |||||
if (!Plan::find($allegedly_unique)) { | |||||
$plan->{$plan->getKeyName()} = $allegedly_unique; | |||||
break; | |||||
} | |||||
} | |||||
$plan->tenant_id = \config('app.tenant_id'); | $plan->tenant_id = \config('app.tenant_id'); | ||||
} | } | ||||
} | } |