From 30442e66848bd04081eb49107f650ed20e31d2e6 Mon Sep 17 00:00:00 2001 From: iamgergo Date: Fri, 13 Nov 2020 16:16:30 +0100 Subject: [PATCH 1/2] [8.x] Add hasVerifiedEmail scope --- src/Illuminate/Auth/MustVerifyEmail.php | 12 ++++++++++++ src/Illuminate/Contracts/Auth/MustVerifyEmail.php | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Illuminate/Auth/MustVerifyEmail.php b/src/Illuminate/Auth/MustVerifyEmail.php index 8e1ce33fbb9f..b445380c8e9b 100644 --- a/src/Illuminate/Auth/MustVerifyEmail.php +++ b/src/Illuminate/Auth/MustVerifyEmail.php @@ -3,6 +3,7 @@ namespace Illuminate\Auth; use Illuminate\Auth\Notifications\VerifyEmail; +use Illuminate\Database\Eloquent\Builder; trait MustVerifyEmail { @@ -47,4 +48,15 @@ public function getEmailForVerification() { return $this->email; } + + /** + * Scope a query to only include users with verified email. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeHasVerifiedEmail(Builder $query) + { + return $query->whereNotNull('email_verified_at'); + } } diff --git a/src/Illuminate/Contracts/Auth/MustVerifyEmail.php b/src/Illuminate/Contracts/Auth/MustVerifyEmail.php index 5b8b10558164..4dbe2a65c43f 100644 --- a/src/Illuminate/Contracts/Auth/MustVerifyEmail.php +++ b/src/Illuminate/Contracts/Auth/MustVerifyEmail.php @@ -2,6 +2,8 @@ namespace Illuminate\Contracts\Auth; +use Illuminate\Database\Eloquent\Builder; + interface MustVerifyEmail { /** @@ -31,4 +33,12 @@ public function sendEmailVerificationNotification(); * @return string */ public function getEmailForVerification(); + + /** + * Scope a query to only include users with verified email. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeHasVerifiedEmail(Builder $query); } From b3ba740c823749ffa9b079bbc6cf436b725fec2f Mon Sep 17 00:00:00 2001 From: iamgergo Date: Fri, 13 Nov 2020 16:44:26 +0100 Subject: [PATCH 2/2] remove scope from contract --- src/Illuminate/Contracts/Auth/MustVerifyEmail.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Illuminate/Contracts/Auth/MustVerifyEmail.php b/src/Illuminate/Contracts/Auth/MustVerifyEmail.php index 4dbe2a65c43f..5b8b10558164 100644 --- a/src/Illuminate/Contracts/Auth/MustVerifyEmail.php +++ b/src/Illuminate/Contracts/Auth/MustVerifyEmail.php @@ -2,8 +2,6 @@ namespace Illuminate\Contracts\Auth; -use Illuminate\Database\Eloquent\Builder; - interface MustVerifyEmail { /** @@ -33,12 +31,4 @@ public function sendEmailVerificationNotification(); * @return string */ public function getEmailForVerification(); - - /** - * Scope a query to only include users with verified email. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeHasVerifiedEmail(Builder $query); }