setTable('lead_donotcontact') ->setCustomRepositoryClass(DoNotContactRepository::class) ->addIndex(['lead_id', 'channel', 'reason'], 'leadid_reason_channel') ->addIndex(['reason'], 'dnc_reason_search') ->addIndex(['date_added'], 'dnc_date_added'); $builder->addId(); $builder->addLead(true, 'CASCADE', false, 'doNotContact'); $builder->addDateAdded(); $builder->createField('reason', 'smallint') ->build(); $builder->createField('channel', 'string') ->build(); $builder->addNamedField('channelId', 'integer', 'channel_id', true); $builder->createField('comments', 'text') ->nullable() ->build(); } /** * Prepares the metadata for API usage. */ public static function loadApiMetadata(ApiMetadataDriver $metadata): void { $metadata->setGroupPrefix('doNotContact') ->addListProperties( [ 'id', 'dateAdded', 'reason', 'comments', 'channel', 'channelId', ] ) ->addProperties( [ 'lead', ] ) ->build(); } /** * @return int */ public function getId() { return $this->id; } /** * @return Lead */ public function getLead() { return $this->lead; } /** * @return DoNotContact */ public function setLead(Lead $lead) { $this->lead = $lead; return $this; } /** * @return \DateTimeInterface */ public function getDateAdded() { return $this->dateAdded; } /** * @return DoNotContact */ public function setDateAdded(\DateTime $dateAdded) { $this->dateAdded = $dateAdded; return $this; } /** * @return int */ public function getReason() { return $this->reason; } /** * @param int $reason * * @return DoNotContact */ public function setReason($reason) { $this->reason = $reason; return $this; } /** * @return string */ public function getComments() { return $this->comments; } /** * @param string $comments * * @return DoNotContact */ public function setComments($comments) { $this->comments = InputHelper::string((string) $comments); return $this; } /** * @return string */ public function getChannel() { return $this->channel; } /** * @param string $channel * * @return DoNotContact */ public function setChannel($channel) { $this->channel = $channel; return $this; } /** * @return mixed */ public function getChannelId() { return $this->channelId; } /** * @param mixed $channelId * * @return DoNotContact */ public function setChannelId($channelId) { $this->channelId = $channelId; return $this; } }