<?php
namespace App\Entity\User;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\User\CarrierRepository;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Ramsey\Uuid\Uuid;
use DateTime;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={"Carrier:io","Carrier:output"}},
* "denormalization_context"={"groups"={"Carrier:io","Carrier:input"}}
* },
* collectionOperations={
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* },
* },
* itemOperations={
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* },
* }
* )
*
* @ORM\Entity(repositoryClass=CarrierRepository::class)
*/
class Carrier
{
const GENDER_MALE = 'Garçon';
const GENDER_FEMALE = 'Fille';
const GENDER_LIST = [
self::GENDER_MALE,
self::GENDER_FEMALE,
];
/**
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
* @SerializedName("id")
* @Assert\Uuid()
* @Groups({
* "Carrier:io",
* "User:output",
* })
*/
private string $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="carriers")
* @ORM\JoinColumn(nullable=false)
* @Groups({
* "Carrier:io",
* })
*/
private $user;
/**
* @ORM\Column(type="string", length=6, columnDefinition="ENUM('Garçon', 'Fille')")
* @SerializedName("gender")
* @Assert\Length(max="6")
* @Assert\Choice(choices=Carrier::GENDER_LIST)
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?string $gender = null;
/**
* @ORM\Column(type="string", length=37)
* @SerializedName("carrier_first_name")
* @Assert\NotBlank()
* @Assert\Length(max="37")
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private string $carrierFirstName;
/**
* @ORM\Column(type="datetime", nullable=true)
* @SerializedName("date_of_birth_carrier")
* @Assert\GreaterThan("1900-01-01")
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?DateTime $dateOfBirthCarrier = null;
/**
* @ORM\Column(type="string", length=10, nullable=true)
* @SerializedName("carrier_mobile_phone_number")
* @Assert\Regex(
* pattern="/^((\+)33|0)[1-9](\d{2}){4}$/",
* message="The phone number is incorrect",
* groups={"Carrier:io", "User:io"}
* )
* @Assert\Length(
* max="10",
* groups={"Carrier:io", "User:io"}
* )
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?string $carrierMobilePhoneNumber = null;
/**
* @ORM\Column(type="datetime", nullable=true)
* @SerializedName("carrier_treatment_start_date")
* @Assert\NotBlank(message="The start date treatment carrier is required")
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?DateTime $carrierTreatmentStartDate = null;
/**
* @ORM\Column(type="datetime", nullable=true)
* @SerializedName("delivery_date_miyosmart")
* @Assert\NotBlank(message="The Miyosmart delivery date is required")
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?DateTime $deliveryDateMiyosmart = null;
/**
* @ORM\Column(type="string", nullable=true)
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?string $consent = null;
/**
* @ORM\Column(type="string", nullable=true)
* @Groups({
* "Carrier:io",
* "User:io",
* })
*/
private ?string $equipment = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?string
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getCarrierFirstName(): ?string
{
return $this->carrierFirstName;
}
public function setCarrierFirstName(string $carrierFirstName): self
{
$this->carrierFirstName = $carrierFirstName;
return $this;
}
public function getDateOfBirthCarrier(): ?DateTime
{
return $this->dateOfBirthCarrier;
}
public function setDateOfBirthCarrier(?DateTime $dateOfBirthCarrier): self
{
$this->dateOfBirthCarrier = $dateOfBirthCarrier;
return $this;
}
public function getCarrierMobilePhoneNumber(): ?string
{
return $this->carrierMobilePhoneNumber;
}
public function setCarrierMobilePhoneNumber(?string $carrierMobilePhoneNumber): self
{
$this->carrierMobilePhoneNumber = $carrierMobilePhoneNumber;
return $this;
}
public function getCarrierTreatmentStartDate(): ?DateTime
{
return $this->carrierTreatmentStartDate;
}
public function setCarrierTreatmentStartDate(?DateTime $carrierTreatmentStartDate): self
{
$this->carrierTreatmentStartDate = $carrierTreatmentStartDate;
return $this;
}
public function getDeliveryDateMiyosmart(): ?DateTime
{
return $this->deliveryDateMiyosmart;
}
public function setDeliveryDateMiyosmart(?DateTime $deliveryDateMiyosmart): self
{
$this->deliveryDateMiyosmart = $deliveryDateMiyosmart;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(string $gender): self
{
$this->gender = $gender;
return $this;
}
public function getConsent(): ?string
{
return $this->consent;
}
public function setConsent(?string $consent): self
{
$this->consent = $consent;
return $this;
}
public function getEquipment(): ?string
{
return $this->equipment;
}
public function setEquipment(?string $equipment): self
{
$this->equipment = $equipment;
return $this;
}
}