Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | public function addEntitlement($entitlement) | ||||
return $this->entitlements()->save($entitlement); | return $this->entitlements()->save($entitlement); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Helper to find user by email address, whether it is | * Helper to find user by email address, whether it is | ||||
* main email address, alias or external email | * main email address, alias or external email | ||||
* | * | ||||
* @param string $email Email address | * @param string $email Email address | ||||
* @param bool $external Search also by an external email | |||||
* | * | ||||
* @return \App\User User model object if found | * @return \App\User User model object if found | ||||
*/ | */ | ||||
public static function findByEmail(string $email): ?User | public static function findByEmail(string $email, bool $external = false): ?User | ||||
{ | { | ||||
if (strpos($email, '@') === false) { | if (strpos($email, '@') === false) { | ||||
return null; | return null; | ||||
} | } | ||||
$email = \strtolower($email); | $email = \strtolower($email); | ||||
$user = self::where('email', $email)->first(); | $user = self::where('email', $email)->first(); | ||||
▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines |