'string', ]; /** * The fillable properties. * * @var string[] */ protected $fillable = ['email']; /** * Overrides the models boot method. */ public static function boot() { parent::boot(); self::creating(function ($invite) { if (!$invite->code) { $invite->code = self::generateInviteCode(); } }); } /** * Returns an invite code. * * @return string */ public static function generateInviteCode() { return str_random(20); } /** * Determines if the invite was claimed. * * @return bool */ public function claimed() { return $this->claimed_at !== null; } }