<?php
namespace App\Entity;
use App\Util\TimeUtil;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Entity\Repository\JobAlertRepository")
* @ORM\Table(name="job_alert")
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
class JobAlert
{
public const FREQUENCY_DAILY = TimeUtil::DAY_IN_SECONDS;
public const FREQUENCY_WEEKLY = TimeUtil::WEEK_IN_SECONDS;
public const FREQUENCY_MONTHLY = TimeUtil::MONTH_IN_SECONDS;
public const KEYWORD_FIELD_DONT_SHOW = 0;
public const KEYWORD_FIELD_REQUIRED = 1;
public const KEYWORD_FIELD_OPTIONAL = 2;
/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var DateTime|null
*
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
* @Serializer\Exclude()
*/
private $deletedAt;
/**
* @var User
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
* @Serializer\Exclude()
*/
private $user;
/**
* @var string
* @ORM\Column(type="string", length=170)
*/
#[Assert\NotBlank]
#[Assert\Email]
private $email;
/**
* @var int
* @ORM\Column(type="integer")
*/
private $frequency;
/**
* @var string
* @ORM\Column(type="string", nullable=true, length=170)
*/
private $keyword;
/**
* @var int|null
*
* @ORM\Column(name="`range`", type="integer", nullable=true)
*/
private $range;
/**
* @var string
* @ORM\Column(type="string", length=170, nullable=true)
*/
private $location;
/**
* @var float
* @ORM\Column(type="float", nullable=true)
*/
private $latitude;
/**
* @var float
* @ORM\Column(type="float", nullable=true)
*/
private $longitude;
/**
* @var DateTime
* @ORM\Column(type="datetime", nullable=true)
* @Serializer\Exclude()
*/
private $lastSentOn;
/**
* @var DateTime
* @ORM\Column(type="datetime")
*
* @Gedmo\Timestampable(on="create")
* @Serializer\Exclude()
*/
private $createdOn;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Serializer\Exclude()
*/
private $isActive = true;
/**
* @var JobAlertHistory[]|Collection
*
* @ORM\OneToMany(targetEntity="JobAlertHistory", mappedBy="jobAlert")
* @Serializer\Exclude()
*/
private $historyList;
/**
* Many JobAlerts has Many OptionValues.
*
* @var OptionValue[]|ArrayCollection
*
* @ORM\ManyToMany(targetEntity="OptionValue")
* @ORM\JoinTable(name="job_alert_option_value_option")
*/
private $optionValues;
/**
* @var Company|null
*
* @ORM\ManyToOne(targetEntity="Company")
*/
private $company;
/**
* @var string|null
*
* @ORM\Column(type="string", length=6, nullable=true)
*/
private $locale;
/**
* @var Site|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\Site", fetch="EAGER")
*/
private $site;
/**
* @var string|null
*
* @ORM\Column(type="string", nullable=true)
*/
#[Assert\Length(max: 255)]
private $firstName;
/**
* @var string|null
*
* @ORM\Column(type="string", nullable=true)
*/
#[Assert\Length(max: 255)]
private $lastName;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $lastDateTried;
public function __construct()
{
$this->historyList = new ArrayCollection();
$this->optionValues = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getFrequency(): ?int
{
return $this->frequency;
}
public function setFrequency(int $frequency): self
{
$this->frequency = $frequency;
return $this;
}
public function getKeyword(): ?string
{
return $this->keyword;
}
public function setKeyword(?string $keyword): self
{
$this->keyword = $keyword;
return $this;
}
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(?string $location): self
{
$this->location = $location;
return $this;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function setLatitude(?float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function setLongitude(?float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getLastSentOn(): ?\DateTimeInterface
{
return $this->lastSentOn;
}
public function setLastSentOn(?\DateTimeInterface $lastSentOn): self
{
$this->lastSentOn = $lastSentOn;
return $this;
}
public function getCreatedOn(): ?\DateTimeInterface
{
return $this->createdOn;
}
public function isActive(): bool
{
return $this->isActive;
}
public function setActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection|JobAlertHistory[]
*/
public function getHistoryList(): Collection
{
return $this->historyList;
}
/**&
* @param JobAlertHistory $jobAlertHistory
*
* @return JobAlert
*/
public function addToHistoryList(JobAlertHistory $jobAlertHistory): self
{
if ($this->historyList->contains($jobAlertHistory)) {
return $this;
}
$this->historyList->add($jobAlertHistory);
return $this;
}
public function removeFromHistoryList(JobAlertHistory $jobAlertHistory): self
{
if (!$this->historyList->contains($jobAlertHistory)) {
return $this;
}
$this->historyList->removeElement($jobAlertHistory);
return $this;
}
/**
* @return Collection|OptionValue[]
*/
public function getOptionValues(): Collection
{
return $this->optionValues;
}
/**
* @param OptionValue[]|ArrayCollection $optionValues
*/
public function setOptionValues($optionValues): self
{
$this->optionValues = $optionValues;
return $this;
}
public function addOptionValue(OptionValue $optionValue): self
{
if (!$this->optionValues->contains($optionValue)) {
$this->optionValues[] = $optionValue;
}
return $this;
}
public function removeOptionValue(OptionValue $optionValue): self
{
if ($this->optionValues->contains($optionValue)) {
$this->optionValues->removeElement($optionValue);
}
return $this;
}
public function getRange(): ?int
{
return $this->range;
}
public function setRange(?int $range): self
{
$this->range = $range;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): self
{
$this->locale = $locale;
return $this;
}
public function getSite(): ?Site
{
return $this->site;
}
public function setSite(?Site $site): self
{
$this->site = $site;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function setCreatedOn(\DateTimeInterface $createdOn): self
{
$this->createdOn = $createdOn;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function addHistoryList(JobAlertHistory $historyList): self
{
if (!$this->historyList->contains($historyList)) {
$this->historyList[] = $historyList;
$historyList->setJobAlert($this);
}
return $this;
}
public function removeHistoryList(JobAlertHistory $historyList): self
{
if ($this->historyList->contains($historyList)) {
$this->historyList->removeElement($historyList);
// set the owning side to null (unless already changed)
if ($historyList->getJobAlert() === $this) {
$historyList->setJobAlert(null);
}
}
return $this;
}
public function getLastDateTried(): ?\DateTimeInterface
{
return $this->lastDateTried;
}
public function setLastDateTried(?\DateTimeInterface $lastDateTried): self
{
$this->lastDateTried = $lastDateTried;
return $this;
}
}