mohammad-fouladgar /
laravel-mobile-verification
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Fouladgar\MobileVerification\Concerns; |
||||||
| 4 | |||||||
| 5 | use Fouladgar\MobileVerification\Notifications\VerifyMobile as VerifyMobileNotification; |
||||||
| 6 | use Illuminate\Config\Repository; |
||||||
| 7 | |||||||
| 8 | trait MustVerifyMobile |
||||||
| 9 | { |
||||||
| 10 | /** |
||||||
| 11 | * Determine if the user has verified their mobile number. |
||||||
| 12 | */ |
||||||
| 13 | public function hasVerifiedMobile(): bool |
||||||
| 14 | { |
||||||
| 15 | return null !== $this->mobile_verified_at; |
||||||
| 16 | } |
||||||
| 17 | |||||||
| 18 | /** |
||||||
| 19 | * Mark the given user's mobile as verified. |
||||||
| 20 | */ |
||||||
| 21 | public function markMobileAsVerified(): bool |
||||||
| 22 | { |
||||||
| 23 | return $this->forceFill(['mobile_verified_at' => $this->freshTimestamp()])->save(); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
It seems like
freshTimestamp() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 24 | } |
||||||
| 25 | |||||||
| 26 | /** |
||||||
| 27 | * Send the mobile verification notification. |
||||||
| 28 | */ |
||||||
| 29 | public function sendMobileVerifierNotification(string $token): void |
||||||
| 30 | { |
||||||
| 31 | $this->notify(new VerifyMobileNotification($token)); |
||||||
|
0 ignored issues
–
show
It seems like
notify() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 32 | } |
||||||
| 33 | |||||||
| 34 | /** |
||||||
| 35 | * Get the mobile number that should be used for verification. |
||||||
| 36 | */ |
||||||
| 37 | public function getMobileForVerification(): string |
||||||
| 38 | { |
||||||
| 39 | return $this->{$this->getMobileField()}; |
||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | /** |
||||||
| 43 | * Get the recipients of the given message. |
||||||
| 44 | * |
||||||
| 45 | * @return mixed |
||||||
| 46 | */ |
||||||
| 47 | public function routeNotificationForVerificationMobile(): string |
||||||
| 48 | { |
||||||
| 49 | return $this->{$this->getMobileField()}; |
||||||
| 50 | } |
||||||
| 51 | |||||||
| 52 | /** |
||||||
| 53 | * @return Repository|mixed |
||||||
| 54 | */ |
||||||
| 55 | private function getMobileField() |
||||||
| 56 | { |
||||||
| 57 | return config('mobile_verifier.mobile_column', 'mobile'); |
||||||
| 58 | } |
||||||
| 59 | } |
||||||
| 60 |