src/Entity/User/Address/Delivery.php line 64

Open in your IDE?
  1. <?php
  2. namespace App\Entity\User\Address;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\Segmentation\Department;
  5. use App\Entity\User\User;
  6. use App\Repository\User\Address\DeliveryRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JMS\Serializer\Annotation\ExclusionPolicy;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass=DeliveryRepository::class)
  14.  * @ExclusionPolicy("all")
  15.  * @ApiResource(
  16.  *     shortName="address-delivery",
  17.  *     attributes={
  18.  *          "normalization_context"={
  19.  *              "groups"={
  20.  *                  "AddressDelivery:output",
  21.  *                  "AddressDelivery:io",
  22.  *               }
  23.  *          },
  24.  *          "denormalization_context"={
  25.  *              "groups"={
  26.  *                  "AddressDelivery:input",
  27.  *                  "AddressDelivery:io",
  28.  *              }
  29.  *          }
  30.  *      },
  31.  *     collectionOperations={
  32.  *          "post"={
  33.  *              "method"="POST",
  34.  *              "access_control"="is_granted('ROLE_USER')"
  35.  *          },
  36.  *          "get"={
  37.  *              "method"="GET",
  38.  *              "access_control"="is_granted('ROLE_USER')",
  39.  *          },
  40.  *          "public-post"={
  41.  *              "method"="POST",
  42.  *              "path"="/public/address-deliveries",
  43.  *              "access_control"="is_granted('ROLE_PUBLIC')",
  44.  *              "validation_groups"={"Default", "Create"}
  45.  *          },
  46.  *     },
  47.  *     itemOperations={
  48.  *          "get"={
  49.  *              "method"="GET",
  50.  *              "access_control"="is_granted('ROLE_USER')",
  51.  *          },
  52.  *          "put"={
  53.  *              "method"="PUT",
  54.  *              "access_control"="is_granted('ROLE_USER')",
  55.  *              "validation_groups"={"put_address_delivery"}
  56.  *          },
  57.  *     },
  58.  * )
  59.  */
  60. class Delivery extends Address
  61. {
  62.     /**
  63.      * @ORM\Column(type="string", length=25)
  64.      * @SerializedName("first_name")
  65.      * @Assert\NotBlank()
  66.      * @Assert\Length(max="25")
  67.      * @Groups({
  68.      *     "AddressDelivery:io",
  69.      *     "User:io",
  70.      * })
  71.      */
  72.     private string $firstName;
  73.     /**
  74.      * @ORM\Column(type="string", length=25)
  75.      * @SerializedName("last_name")
  76.      * @Assert\NotBlank()
  77.      * @Assert\Length(max="25")
  78.      * @Groups({
  79.      *     "AddressDelivery:io",
  80.      *     "User:io",
  81.      * })
  82.      */
  83.     private string $lastName;
  84.     /**
  85.      * @ORM\Column(type="string", length=10, nullable=true)
  86.      * @SerializedName("phone_number")
  87.      * @Assert\Length(max="10")
  88.      * @Groups({
  89.      *     "AddressDelivery:io",
  90.      *     "User:io",
  91.      * })
  92.      */
  93.     private ?string $phoneNumber;
  94.     /**
  95.      * @ORM\Column(type="string", length=255, nullable=true)
  96.      * @SerializedName("extra_information")
  97.      * @Groups({
  98.      *     "AddressDelivery:io",
  99.      *     "User:io",
  100.      * })
  101.      */
  102.     private ?string $extraInformation;
  103.     /**
  104.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="addressesDelivery")
  105.      * @ORM\JoinColumn(nullable=false)
  106.      * @SerializedName("user")
  107.      * @Groups({
  108.      *     "AddressDelivery:io",
  109.      * })
  110.      */
  111.     private $user;
  112.     /**
  113.      * @var Department
  114.      *
  115.      * @ORM\ManyToOne(targetEntity="App\Entity\Segmentation\Department", inversedBy="delivery")
  116.      */
  117.     private $department;
  118.     public function getUser(): ?User
  119.     {
  120.         return $this->user;
  121.     }
  122.     public function setUser(?User $user): self
  123.     {
  124.         $this->user $user;
  125.         return $this;
  126.     }
  127.     public function getDepartment(): Department
  128.     {
  129.         return $this->department;
  130.     }
  131.     public function setDepartment(Department $department): Address
  132.     {
  133.         $this->department $department;
  134.         return $this;
  135.     }
  136.     public function getFirstName(): string
  137.     {
  138.         return $this->firstName;
  139.     }
  140.     public function setFirstName(string $firstName): Delivery
  141.     {
  142.         $this->firstName $firstName;
  143.         return $this;
  144.     }
  145.     public function getLastName(): string
  146.     {
  147.         return $this->lastName;
  148.     }
  149.     public function setLastName(string $lastName): Delivery
  150.     {
  151.         $this->lastName $lastName;
  152.         return $this;
  153.     }
  154.     public function getPhoneNumber(): ?string
  155.     {
  156.         return $this->phoneNumber;
  157.     }
  158.     public function setPhoneNumber(?string $phoneNumber): Delivery
  159.     {
  160.         $this->phoneNumber $phoneNumber;
  161.         return $this;
  162.     }
  163.     public function getExtraInformation(): ?string
  164.     {
  165.         return $this->extraInformation;
  166.     }
  167.     /**
  168.      * @param string|null $extraInformation
  169.      * @return Delivery
  170.      */
  171.     public function setExtraInformation(?string $extraInformation): Delivery
  172.     {
  173.         $this->extraInformation $extraInformation;
  174.         return $this;
  175.     }
  176. }