<?php
namespace JanusHercules\SelfServiceTrafficCampaign\Domain\Entity;
use App\Entity\RecurrentJob;
use App\Utility\DatabaseIdGenerator;
use App\Utility\DateTimeUtility;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Exception;
#[ORM\Entity]
#[ORM\Table(name: 'self_service_traffic_campaigns')]
class SelfServiceTrafficCampaign
{
/**
* @throws Exception
*/
public function __construct(
) {
$this->createdAt = DateTimeUtility::createDateTimeUtc();
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
#[ORM\Column(
type : Types::GUID,
unique: true
)]
private ?string $id;
public function getId(): ?string
{
return $this->id;
}
public function setId(?string $id): void
{
$this->id = $id;
}
#[ORM\Column(
type : Types::DATETIME_MUTABLE,
nullable: false
)]
private DateTime $createdAt;
public function setCreatedAt(DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
#[ORM\ManyToOne(
targetEntity: RecurrentJob::class,
inversedBy: 'selfServiceTrafficCampaigns'
)]
#[ORM\JoinColumn(
name: 'recurrent_jobs_id',
referencedColumnName: 'id',
nullable: true,
onDelete: 'SET NULL'
)]
private ?RecurrentJob $recurrentJob;
public function getRecurrentJobId(): ?RecurrentJob
{
return $this->recurrentJob;
}
public function setRecurrentJob(?RecurrentJob $recurrentJob): void
{
$this->recurrentJob = $recurrentJob;
}
#[ORM\OneToOne(
targetEntity: SelfServiceTrafficCampaignBooking::class,
inversedBy: 'campaign',
cascade: ['persist']
)]
#[ORM\JoinColumn(
name : 'self_service_traffic_campaign_booking_id',
referencedColumnName: 'id',
nullable : true,
onDelete : 'CASCADE'
)]
private SelfServiceTrafficCampaignBooking $booking;
public function getBooking(): SelfServiceTrafficCampaignBooking
{
return $this->booking;
}
public function setBooking(SelfServiceTrafficCampaignBooking $booking): void
{
$this->booking = $booking;
}
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)]
private DateTime $startDate;
public function getStartDate(): DateTime
{
return $this->startDate;
}
public function setStartDate(DateTime $startDate): void
{
$this->startDate = $startDate;
}
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)]
private DateTime $endDate;
public function getEndDate(): DateTime
{
return $this->endDate;
}
public function setEndDate(DateTime $endDate): void
{
$this->endDate = $endDate;
}
#[ORM\Column(
type: Types::BOOLEAN,
)]
private bool $deleted = false;
public function isDeleted(): bool
{
return $this->deleted;
}
public function setDeleted(bool $deleted): void
{
$this->deleted = $deleted;
}
}