modularsoftware /
genealogy
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Traits; |
||
| 4 | |||
| 5 | use App\Logic\Activation\ActivationRepository; |
||
| 6 | use App\Models\User; |
||
| 7 | use Illuminate\Support\Facades\Validator; |
||
| 8 | |||
| 9 | trait ActivationTrait |
||
| 10 | { |
||
| 11 | public function initiateEmailActivation(User $user) |
||
| 12 | { |
||
| 13 | // if (!config('settings.activation') || !$this->validateEmail($user)) { |
||
| 14 | // return true; |
||
| 15 | // } |
||
| 16 | |||
| 17 | $activationRepostory = new ActivationRepository(); |
||
| 18 | $activationRepostory->createTokenAndSendEmail($user); |
||
| 19 | } |
||
| 20 | |||
| 21 | public function initiateEmailActivationApi(User $user) |
||
| 22 | { |
||
| 23 | if (! config('settings.activation') || ! $this->validateEmail($user)) { |
||
| 24 | return true; |
||
| 25 | } |
||
| 26 | |||
| 27 | $activationRepostory = new ActivationRepository(); |
||
| 28 | $activationRepostory->createTokenAndSendEmailApi($user); |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function validateEmail(User $user) |
||
| 32 | { |
||
| 33 | $validator = Validator::make(['email' => $user->email], ['email' => 'required|email']); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 34 | |||
| 35 | if ($validator->fails()) { |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 39 | return true; |
||
| 40 | } |
||
| 41 | } |
||
| 42 |