'required|email|unique:subscribers', ]; /** * The fillable properties. * * @var string[] */ protected $fillable = ['email']; /** * The attributes that should be mutated to dates. * * @var array */ protected $dates = ['verified_at']; /** * The attributes that should be casted to native types. * * @var string[] */ protected $casts = [ 'email' => 'string', 'verify_code' => 'string', ]; /** * Overrides the models boot method. */ public static function boot() { parent::boot(); self::creating(function ($user) { if (!$user->verify_code) { $user->verify_code = self::generateVerifyCode(); } }); } /** * Determines if the subscriber is verified. * * @return bool */ public function verified() { return !is_null($this->verified_at); } /** * Returns an new verify code. * * @return string */ public static function generateVerifyCode() { return str_random(42); } /** * Get the presenter class. * * @return string */ public function getPresenterClass() { return SubscriberPresenter::class; } }