Verified.php 989 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Listeners;
  3. use App\Settings\UserSettings;
  4. class Verified
  5. {
  6. private $server_limit_after_verify_email;
  7. private $credits_reward_after_verify_email;
  8. /**
  9. * Create the event listener.
  10. *
  11. * @return void
  12. */
  13. public function __construct(UserSettings $user_settings)
  14. {
  15. $this->server_limit_after_verify_email = $user_settings->server_limit_after_verify_email;
  16. $this->credits_reward_after_verify_email = $user_settings->credits_reward_after_verify_email;
  17. }
  18. /**
  19. * Handle the event.
  20. *
  21. * @param object $event
  22. * @return void
  23. */
  24. public function handle($event)
  25. {
  26. if (!$event->user->email_verified_reward) {
  27. $event->user->increment('server_limit', $this->server_limit_after_verify_email);
  28. $event->user->increment('credits', $this->credits_reward_after_verify_email);
  29. $event->user->update(['email_verified_reward' => true]);
  30. }
  31. }
  32. }