/** * Attempt to activate a user account by the user ID and activation code. * * @param integer $id * @param string $activationCode * @return boolean */ public function activate($id = 0, $activationCode = '') { $user = User::find($id); if (!empty($user) && !$user->isActivated() && ($this->is('admin') || $activationCode == $user->activation_code)) { $user->fill(['activated_at' => date('Y-m-d H:i:s')])->save(); return true; } return false; }
/** * Get a user by their username or email address. * * @param string $identifier * @return boolean */ public static function getByUsernameOrEmail($identifier = '') { $identifier = trim(strtolower($identifier)); return User::where(function ($query) use($identifier) { $query->where(DB::raw('lower(name)'), $identifier)->orWhere(DB::raw('lower(email)'), $identifier); })->first(); }