src/Entity/LivingCostSubmission.php line 39
<?php
namespace App\Entity;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use Doctrine\DBAL\Types\Types;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Delete;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\LivingCostStatistics;
use ApiPlatform\Metadata\ApiResource;
use Gedmo\Mapping\Annotation as Gedmo;
use ApiPlatform\Metadata\GetCollection;
use App\Validator\Constraints as AppAssert;
use App\Repository\LivingCostSubmissionRepository;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: LivingCostSubmissionRepository::class)]
#[AppAssert\LivingCostCityNotChangeable]
#[ApiResource(
operations: [
new GetCollection(),
new Post(
denormalizationContext: [
'groups' => ['post'],
],
normalizationContext: [
'groups' => ['post'],
]
),
new Delete(),
]
)]
/**
* Model for LivingCostSubbmission entity.
*/
class LivingCostSubmission
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['post', 'patch', 'get'])]
private ?int $id = null;
#[ORM\Column]
#[Groups(['post', 'patch', 'get'])]
private ?int $monthlyAccommodationCost = null;
#[ORM\Column]
#[Groups(['post', 'patch', 'get']) ]
private ?int $monthlyLivingCost = null;
#[ORM\Column]
#[Groups(['post', 'patch', 'get'])]
private ?int $userId = null;
#[ORM\ManyToOne(inversedBy: 'livingCostSubmissions')]
private ?LivingCostStatistics $livingCostStatistics = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
#[Gedmo\Timestampable(on: "create")]
#[Groups(['get'])]
private ?\DateTimeImmutable $created = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
#[Gedmo\Timestampable(on: "update")]
#[Groups(['get'])]
private ?\DateTimeImmutable $updated = null;
#[ORM\ManyToOne(cascade: ['persist'])]
#[Groups(['post', 'get'])]
private ?City $city = null;
#[ORM\Column]
#[Groups(['post', 'get'])]
private ?int $stayDurationInMonths = null;
#[Assert\NotBlank]
#[Assert\Choice(['On','on'])]
#[Groups(['post', 'patch'])]
private ?string $termsAccepted;
/**
* Returns id.
*
* @return integer|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* Returns monthly accommodation costs.
*
* @return integer|null
*/
public function getMonthlyAccommodationCost(): ?int
{
return $this->monthlyAccommodationCost;
}
/**
* Sets monthly accommodation cost.
*
* @param integer $monthlyAccommodationCost
*
* @return self
*/
public function setMonthlyAccommodationCost(int $monthlyAccommodationCost): self
{
$this->monthlyAccommodationCost = $monthlyAccommodationCost;
return $this;
}
/**
* Returns monthly living cost.
*
* @return integer|null
*/
public function getMonthlyLivingCost(): ?int
{
return $this->monthlyLivingCost;
}
/**
* Sets mothly accommodation cost.
*
* @param integer $monthlyLivingCost
*
* @return self
*/
public function setMonthlyLivingCost(int $monthlyLivingCost): self
{
$this->monthlyLivingCost = $monthlyLivingCost;
return $this;
}
/**
* Returns user id. User id is an external value, not the Symfony user id.
*
* @return integer|null
*/
public function getUserId(): ?int
{
return $this->userId;
}
/**
* Sets external user id.
*
* @param integer $userId
*
* @return self
*/
public function setUserId(int $userId): self
{
$this->userId = $userId;
return $this;
}
/**
* Returns related living cost statistics entity.
*
* @return LivingCostStatistics|null
*/
public function getLivingCostStatistics(): ?LivingCostStatistics
{
return $this->livingCostStatistics;
}
/**
* Sets relation to a living cost entity.
*
* @param LivingCostStatistics|null $livingCostStatistics
*
* @return self
*/
public function setLivingCostStatistics(?LivingCostStatistics $livingCostStatistics): self
{
$this->livingCostStatistics = $livingCostStatistics;
return $this;
}
/**
* Returns the date the submission was created.
*
* @return \DateTimeImmutable|null
*/
public function getCreated(): ?\DateTimeImmutable
{
return $this->created;
}
/**
* Sets the time the submission was created.
*
* @param \DateTimeImmutable $created
*
* @return self
*/
public function setCreated(\DateTimeImmutable $created): self
{
$this->created = $created;
return $this;
}
/**
* Returns the date the submission was updated.
*
* @return \DateTimeImmutable|null
*/
public function getUpdated(): ?\DateTimeImmutable
{
return $this->updated;
}
/**
* Sets the date the submission was updated.
*
* @param \DateTimeImmutable $updated
*
* @return self
*/
public function setUpdated(\DateTimeImmutable $updated): self
{
$this->updated = $updated;
return $this;
}
/**
* Returns the related city entity.
*
* @return City|null
*/
public function getCity(): ?City
{
return $this->city;
}
/**
* Sets the related city entity.
*
* @param City $city
*
* @return self
*/
public function setCity(City $city): self
{
$this->city = $city;
return $this;
}
/**
* Returns the stay duration in months.
*
* @return integer|null
*/
public function getStayDurationInMonths(): ?int
{
return $this->stayDurationInMonths;
}
/**
* Sets the stay duration in months.
*
* @param integer $stayDurationInMonths
*
* @return self
*/
public function setStayDurationInMonths(int $stayDurationInMonths): self
{
$this->stayDurationInMonths = $stayDurationInMonths;
return $this;
}
/**
* Returns the unstored terms accepted property value.
*
* @return string
*/
public function getTermsAccepted(): string
{
return $this->termsAccepted;
}
/**
* Returns the unstored terms accepted property value.
*
* @return string
*/
public function setTermsAccepted(string $termsAccepted): self
{
$this->termsAccepted = $termsAccepted;
return $this;
}
}