src/Entity/User/Carrier.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity\User;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\User\CarrierRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Ramsey\Uuid\Doctrine\UuidGenerator;
  7. use Ramsey\Uuid\Uuid;
  8. use DateTime;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ApiResource(
  14.  *       attributes={
  15.  *           "normalization_context"={"groups"={"Carrier:io","Carrier:output"}},
  16.  *           "denormalization_context"={"groups"={"Carrier:io","Carrier:input"}}
  17.  *       },
  18.  *      collectionOperations={
  19.  *           "get"={
  20.  *               "method"="GET",
  21.  *               "access_control"="is_granted('ROLE_USER')",
  22.  *           },
  23.  *      },
  24.  *      itemOperations={
  25.  *           "get"={
  26.  *               "method"="GET",
  27.  *               "access_control"="is_granted('ROLE_USER')",
  28.  *           },
  29.  *       }
  30.  *  )
  31.  *
  32.  * @ORM\Entity(repositoryClass=CarrierRepository::class)
  33.  */
  34. class Carrier
  35. {
  36.     const GENDER_MALE 'Garçon';
  37.     const GENDER_FEMALE 'Fille';
  38.     const GENDER_LIST = [
  39.         self::GENDER_MALE,
  40.         self::GENDER_FEMALE,
  41.     ];
  42.     /**
  43.      * @ORM\Id
  44.      * @ORM\Column(type="uuid", unique=true)
  45.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  46.      * @SerializedName("id")
  47.      * @Assert\Uuid()
  48.      * @Groups({
  49.      *     "Carrier:io",
  50.      *     "User:output",
  51.      * })
  52.      */
  53.     private string $id;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="carriers")
  56.      * @ORM\JoinColumn(nullable=false)
  57.      * @Groups({
  58.      *      "Carrier:io",
  59.      * })
  60.      */
  61.     private $user;
  62.     /**
  63.      * @ORM\Column(type="string", length=6, columnDefinition="ENUM('Garçon', 'Fille')")
  64.      * @SerializedName("gender")
  65.      * @Assert\Length(max="6")
  66.      * @Assert\Choice(choices=Carrier::GENDER_LIST)
  67.      * @Groups({
  68.      *      "Carrier:io",
  69.      *      "User:io",
  70.      * })
  71.      */
  72.     private ?string $gender null;
  73.     /**
  74.      * @ORM\Column(type="string", length=37)
  75.      * @SerializedName("carrier_first_name")
  76.      * @Assert\NotBlank()
  77.      * @Assert\Length(max="37")
  78.      * @Groups({
  79.      *      "Carrier:io",
  80.      *      "User:io",
  81.      * })
  82.      */
  83.     private string $carrierFirstName;
  84.     /**
  85.      * @ORM\Column(type="datetime", nullable=true)
  86.      * @SerializedName("date_of_birth_carrier")
  87.      * @Assert\GreaterThan("1900-01-01")
  88.      * @Groups({
  89.      *      "Carrier:io",
  90.      *      "User:io",
  91.      * })
  92.      */
  93.     private ?DateTime $dateOfBirthCarrier null;
  94.     /**
  95.      * @ORM\Column(type="string", length=10, nullable=true)
  96.      * @SerializedName("carrier_mobile_phone_number")
  97.      * @Assert\Regex(
  98.      *     pattern="/^((\+)33|0)[1-9](\d{2}){4}$/",
  99.      *     message="The phone number is incorrect",
  100.      *     groups={"Carrier:io", "User:io"}
  101.      * )
  102.      * @Assert\Length(
  103.      *     max="10",
  104.      *     groups={"Carrier:io", "User:io"}
  105.      * )
  106.      * @Groups({
  107.      *      "Carrier:io",
  108.      *      "User:io",
  109.      * })
  110.      */
  111.     private ?string $carrierMobilePhoneNumber null;
  112.     /**
  113.      * @ORM\Column(type="datetime", nullable=true)
  114.      * @SerializedName("carrier_treatment_start_date")
  115.      * @Assert\NotBlank(message="The start date treatment carrier is required")
  116.      * @Groups({
  117.      *      "Carrier:io",
  118.      *      "User:io",
  119.      * })
  120.      */
  121.     private ?DateTime $carrierTreatmentStartDate null;
  122.     /**
  123.      * @ORM\Column(type="datetime", nullable=true)
  124.      * @SerializedName("delivery_date_miyosmart")
  125.      * @Assert\NotBlank(message="The Miyosmart delivery date is required")
  126.      * @Groups({
  127.      *      "Carrier:io",
  128.      *      "User:io",
  129.      * })
  130.      */
  131.     private ?DateTime $deliveryDateMiyosmart null;
  132.     /**
  133.      * @ORM\Column(type="string", nullable=true)
  134.      * @Groups({
  135.      *      "Carrier:io",
  136.      *      "User:io",
  137.      * })
  138.      */
  139.     private ?string $consent null;
  140.     /**
  141.      * @ORM\Column(type="string", nullable=true)
  142.      * @Groups({
  143.      *      "Carrier:io",
  144.      *      "User:io",
  145.      * })
  146.      */
  147.     private ?string $equipment null;
  148.     public function __construct()
  149.     {
  150.         $this->id Uuid::uuid4();
  151.     }
  152.     public function getId(): ?string
  153.     {
  154.         return $this->id;
  155.     }
  156.     public function getUser(): ?User
  157.     {
  158.         return $this->user;
  159.     }
  160.     public function setUser(?User $user): self
  161.     {
  162.         $this->user $user;
  163.         return $this;
  164.     }
  165.     public function getCarrierFirstName(): ?string
  166.     {
  167.         return $this->carrierFirstName;
  168.     }
  169.     public function setCarrierFirstName(string $carrierFirstName): self
  170.     {
  171.         $this->carrierFirstName $carrierFirstName;
  172.         return $this;
  173.     }
  174.     public function getDateOfBirthCarrier(): ?DateTime
  175.     {
  176.         return $this->dateOfBirthCarrier;
  177.     }
  178.     public function setDateOfBirthCarrier(?DateTime $dateOfBirthCarrier): self
  179.     {
  180.         $this->dateOfBirthCarrier $dateOfBirthCarrier;
  181.         return $this;
  182.     }
  183.     public function getCarrierMobilePhoneNumber(): ?string
  184.     {
  185.         return $this->carrierMobilePhoneNumber;
  186.     }
  187.     public function setCarrierMobilePhoneNumber(?string $carrierMobilePhoneNumber): self
  188.     {
  189.         $this->carrierMobilePhoneNumber $carrierMobilePhoneNumber;
  190.         return $this;
  191.     }
  192.     public function getCarrierTreatmentStartDate(): ?DateTime
  193.     {
  194.         return $this->carrierTreatmentStartDate;
  195.     }
  196.     public function setCarrierTreatmentStartDate(?DateTime $carrierTreatmentStartDate): self
  197.     {
  198.         $this->carrierTreatmentStartDate $carrierTreatmentStartDate;
  199.         return $this;
  200.     }
  201.     public function getDeliveryDateMiyosmart(): ?DateTime
  202.     {
  203.         return $this->deliveryDateMiyosmart;
  204.     }
  205.     public function setDeliveryDateMiyosmart(?DateTime $deliveryDateMiyosmart): self
  206.     {
  207.         $this->deliveryDateMiyosmart $deliveryDateMiyosmart;
  208.         return $this;
  209.     }
  210.     public function getGender(): ?string
  211.     {
  212.         return $this->gender;
  213.     }
  214.     public function setGender(string $gender): self
  215.     {
  216.         $this->gender $gender;
  217.         return $this;
  218.     }
  219.     public function getConsent(): ?string
  220.     {
  221.         return $this->consent;
  222.     }
  223.     public function setConsent(?string $consent): self
  224.     {
  225.         $this->consent $consent;
  226.         return $this;
  227.     }
  228.     public function getEquipment(): ?string
  229.     {
  230.         return $this->equipment;
  231.     }
  232.     public function setEquipment(?string $equipment): self
  233.     {
  234.         $this->equipment $equipment;
  235.         return $this;
  236.     }
  237. }