| Conditions | 9 |
| Paths | 5 |
| Total Lines | 28 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function authorize(): bool |
||
| 20 | { |
||
| 21 | $user = $this->user() |
||
| 22 | ?? $this->attemptUser() |
||
|
|
|||
| 23 | ?? app('rinvex.fort.user')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); |
||
| 24 | |||
| 25 | if ($user && $user->phone_verified) { |
||
| 26 | // Redirect users if their phone already verified, no need to process their request |
||
| 27 | throw new GenericException(trans('cortex/fort::messages.verification.phone.already_verified'), route('tenantarea.account.settings')); |
||
| 28 | } |
||
| 29 | |||
| 30 | if ($user && ! $user->phone) { |
||
| 31 | // Phone field required before verification |
||
| 32 | throw new GenericException(trans('cortex/fort::messages.account.phone_required'), route('tenantarea.account.settings')); |
||
| 33 | } |
||
| 34 | |||
| 35 | if ($user && ! $user->country_code) { |
||
| 36 | // Country field required for phone verification |
||
| 37 | throw new GenericException(trans('cortex/fort::messages.account.country_required'), route('tenantarea.account.settings')); |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($user && ! $user->email_verified) { |
||
| 41 | // Email verification required for phone verification |
||
| 42 | throw new GenericException(trans('cortex/fort::messages.account.email_verification_required'), route('tenantarea.verification.email.request')); |
||
| 43 | } |
||
| 44 | |||
| 45 | return true; |
||
| 46 | } |
||
| 47 | |||
| 58 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: