/** * Check if new login is always exist * @param string $login * @param int|null $userId * @return bool */ public static function isUniqueLogin($login, $userId = null) { $find = User::where('login', '=', $login); if ($userId !== null && Obj::isLikeInt($userId)) { $find->where('id', '!=', $userId); } return $find->count() === 0; }