src/Entity/LivingCostSubmission.php line 39

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\Get;
  4. use ApiPlatform\Metadata\Post;
  5. use Doctrine\DBAL\Types\Types;
  6. use ApiPlatform\Metadata\Patch;
  7. use ApiPlatform\Metadata\Delete;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use App\Entity\LivingCostStatistics;
  10. use ApiPlatform\Metadata\ApiResource;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use ApiPlatform\Metadata\GetCollection;
  13. use App\Validator\Constraints as AppAssert;
  14. use App\Repository\LivingCostSubmissionRepository;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ORM\Entity(repositoryClassLivingCostSubmissionRepository::class)]
  18. #[AppAssert\LivingCostCityNotChangeable]
  19. #[ApiResource(
  20.     operations: [
  21.         new GetCollection(),
  22.         new Post(
  23.             denormalizationContext: [
  24.                 'groups' => ['post'],
  25.             ],
  26.             normalizationContext: [
  27.                 'groups' => ['post'],
  28.             ]
  29.         ),
  30.         new Delete(),
  31.     ]
  32. )]
  33. /**
  34.  * Model for LivingCostSubbmission entity.
  35.  */
  36. class LivingCostSubmission
  37. {
  38.     #[ORM\Id]
  39.     #[ORM\GeneratedValue]
  40.     #[ORM\Column]
  41.     #[Groups(['post''patch''get'])]
  42.     private ?int $id null;
  43.     #[ORM\Column]
  44.     #[Groups(['post''patch''get'])]
  45.     private ?int $monthlyAccommodationCost null;
  46.     #[ORM\Column]
  47.     #[Groups(['post''patch''get']) ]
  48.     private ?int $monthlyLivingCost null;
  49.     #[ORM\Column]
  50.     #[Groups(['post''patch''get'])]
  51.     private ?int $userId null;
  52.     #[ORM\ManyToOne(inversedBy'livingCostSubmissions')]
  53.     private ?LivingCostStatistics $livingCostStatistics null;
  54.     #[ORM\Column(typeTypes::DATE_IMMUTABLE)]
  55.     #[Gedmo\Timestampable(on"create")]
  56.     #[Groups(['get'])]
  57.     private ?\DateTimeImmutable $created null;
  58.     #[ORM\Column(typeTypes::DATE_IMMUTABLE)]
  59.     #[Gedmo\Timestampable(on"update")]
  60.     #[Groups(['get'])]
  61.     private ?\DateTimeImmutable $updated null;
  62.     #[ORM\ManyToOne(cascade: ['persist'])]
  63.     #[Groups(['post''get'])]
  64.     private ?City $city null;
  65.     #[ORM\Column]
  66.     #[Groups(['post''get'])]
  67.     private ?int $stayDurationInMonths null;
  68.     #[Assert\NotBlank]
  69.     #[Assert\Choice(['On','on'])]
  70.     #[Groups(['post''patch'])]
  71.     private ?string $termsAccepted;
  72.     /**
  73.      * Returns id.
  74.      *
  75.      * @return integer|null
  76.      */
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     /**
  82.      * Returns monthly accommodation costs.
  83.      *
  84.      * @return integer|null
  85.      */
  86.     public function getMonthlyAccommodationCost(): ?int
  87.     {
  88.         return $this->monthlyAccommodationCost;
  89.     }
  90.     /**
  91.      * Sets monthly accommodation cost.
  92.      *
  93.      * @param integer $monthlyAccommodationCost
  94.      *
  95.      * @return self
  96.      */
  97.     public function setMonthlyAccommodationCost(int $monthlyAccommodationCost): self
  98.     {
  99.         $this->monthlyAccommodationCost $monthlyAccommodationCost;
  100.         return $this;
  101.     }
  102.     /**
  103.      * Returns monthly living cost.
  104.      *
  105.      * @return integer|null
  106.      */
  107.     public function getMonthlyLivingCost(): ?int
  108.     {
  109.         return $this->monthlyLivingCost;
  110.     }
  111.     /**
  112.      * Sets mothly accommodation cost.
  113.      *
  114.      * @param integer $monthlyLivingCost
  115.      *
  116.      * @return self
  117.      */
  118.     public function setMonthlyLivingCost(int $monthlyLivingCost): self
  119.     {
  120.         $this->monthlyLivingCost $monthlyLivingCost;
  121.         return $this;
  122.     }
  123.     /**
  124.      * Returns user id. User id is an external value, not the Symfony user id.
  125.      *
  126.      * @return integer|null
  127.      */
  128.     public function getUserId(): ?int
  129.     {
  130.         return $this->userId;
  131.     }
  132.     /**
  133.      * Sets external user id.
  134.      *
  135.      * @param integer $userId
  136.      *
  137.      * @return self
  138.      */
  139.     public function setUserId(int $userId): self
  140.     {
  141.         $this->userId $userId;
  142.         return $this;
  143.     }
  144.     /**
  145.      * Returns related living cost statistics entity.
  146.      *
  147.      * @return LivingCostStatistics|null
  148.      */
  149.     public function getLivingCostStatistics(): ?LivingCostStatistics
  150.     {
  151.         return $this->livingCostStatistics;
  152.     }
  153.     /**
  154.      * Sets relation to a living cost entity.
  155.      *
  156.      * @param LivingCostStatistics|null $livingCostStatistics
  157.      *
  158.      * @return self
  159.      */
  160.     public function setLivingCostStatistics(?LivingCostStatistics $livingCostStatistics): self
  161.     {
  162.         $this->livingCostStatistics $livingCostStatistics;
  163.         return $this;
  164.     }
  165.     /**
  166.      * Returns the date the submission was created.
  167.      *
  168.      * @return \DateTimeImmutable|null
  169.      */
  170.     public function getCreated(): ?\DateTimeImmutable
  171.     {
  172.         return $this->created;
  173.     }
  174.     /**
  175.      * Sets the time the submission was created.
  176.      *
  177.      * @param \DateTimeImmutable $created
  178.      *
  179.      * @return self
  180.      */
  181.     public function setCreated(\DateTimeImmutable $created): self
  182.     {
  183.         $this->created $created;
  184.         return $this;
  185.     }
  186.     /**
  187.      * Returns the date the submission was updated.
  188.      *
  189.      * @return \DateTimeImmutable|null
  190.      */
  191.     public function getUpdated(): ?\DateTimeImmutable
  192.     {
  193.         return $this->updated;
  194.     }
  195.     /**
  196.      * Sets the date the submission was updated.
  197.      *
  198.      * @param \DateTimeImmutable $updated
  199.      *
  200.      * @return self
  201.      */
  202.     public function setUpdated(\DateTimeImmutable $updated): self
  203.     {
  204.         $this->updated $updated;
  205.         return $this;
  206.     }
  207.     /**
  208.      * Returns the related city entity.
  209.      *
  210.      * @return City|null
  211.      */
  212.     public function getCity(): ?City
  213.     {
  214.         return $this->city;
  215.     }
  216.     /**
  217.      * Sets the related city entity.
  218.      *
  219.      * @param City $city
  220.      *
  221.      * @return self
  222.      */
  223.     public function setCity(City $city): self
  224.     {
  225.         $this->city $city;
  226.         return $this;
  227.     }
  228.     /**
  229.      * Returns the stay duration in months.
  230.      *
  231.      * @return integer|null
  232.      */
  233.     public function getStayDurationInMonths(): ?int
  234.     {
  235.         return $this->stayDurationInMonths;
  236.     }
  237.     /**
  238.      * Sets the stay duration in months.
  239.      *
  240.      * @param integer $stayDurationInMonths
  241.      *
  242.      * @return self
  243.      */
  244.     public function setStayDurationInMonths(int $stayDurationInMonths): self
  245.     {
  246.         $this->stayDurationInMonths $stayDurationInMonths;
  247.         return $this;
  248.     }
  249.     /**
  250.      * Returns the unstored terms accepted property value.
  251.      *
  252.      * @return string
  253.      */
  254.     public function getTermsAccepted(): string
  255.     {
  256.         return $this->termsAccepted;
  257.     }
  258.     /**
  259.      * Returns the unstored terms accepted property value.
  260.      *
  261.      * @return string
  262.      */
  263.     public function setTermsAccepted(string $termsAccepted): self
  264.     {
  265.         $this->termsAccepted $termsAccepted;
  266.         return $this;
  267.     }
  268. }