'int', 'email' => 'string', 'verify_code' => 'string', 'verified_at' => 'date', ]; /** * The fillable properties. * * @var string[] */ protected $fillable = ['email']; /** * The validation rules. * * @var string[] */ public $rules = [ 'email' => 'required|email', ]; /** * Overrides the models boot method. */ public static function boot() { parent::boot(); self::creating(function ($user) { if (!$user->verify_code) { $user->verify_code = self::generateVerifyCode(); } }); } /** * Scope a query to only include verified subscribers. * * @param \Illuminate\Database\Eloquent\Builder $query * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeVerified(Builder $query) { return $query->whereNotNull('verified_at'); } /** * Determines if the subscriber is verified. * * @return bool */ public function getIsVerifiedAttribute() { return $this->verified_at !== null; } /** * 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; } }