Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/UserObserver.php
Show All 17 Lines | class UserObserver | ||||
* Ensure that the user is created with a random, large integer. | * Ensure that the user is created with a random, large integer. | ||||
* | * | ||||
* @param \App\User $user The user being created. | * @param \App\User $user The user being created. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function creating(User $user) | public function creating(User $user) | ||||
{ | { | ||||
if (!$user->id) { | |||||
while (true) { | |||||
$allegedly_unique = \App\Utils::uuidInt(); | |||||
if (!User::withTrashed()->find($allegedly_unique)) { | |||||
$user->{$user->getKeyName()} = $allegedly_unique; | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
$user->email = \strtolower($user->email); | $user->email = \strtolower($user->email); | ||||
// only users that are not imported get the benefit of the doubt. | // only users that are not imported get the benefit of the doubt. | ||||
$user->status |= User::STATUS_NEW | User::STATUS_ACTIVE; | $user->status |= User::STATUS_NEW | User::STATUS_ACTIVE; | ||||
$user->tenant_id = \config('app.tenant_id'); | $user->tenant_id = \config('app.tenant_id'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 335 Lines • Show Last 20 Lines |