src/Entity/User/Address/Order.php line 53

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\OrderRepository;
  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=OrderRepository::class)
  14.  * @ExclusionPolicy("all")
  15.  * @ApiResource(
  16.  *     shortName="address-order",
  17.  *     attributes={
  18.  *          "normalization_context"={
  19.  *              "groups"={
  20.  *                  "AddressOrder:output",
  21.  *                  "AddressOrder:io",
  22.  *               }
  23.  *          },
  24.  *          "denormalization_context"={
  25.  *              "groups"={
  26.  *                  "AddressOrder:input",
  27.  *                  "AddressOrder: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.  *     },
  41.  *     itemOperations={
  42.  *          "get"={
  43.  *              "method"="GET",
  44.  *              "access_control"="is_granted('ROLE_USER')",
  45.  *          },
  46.  *     },
  47.  * )
  48.  */
  49. class Order extends Address
  50. {
  51.     /**
  52.      * @ORM\Column(type="string", length=25)
  53.      * @SerializedName("first_name")
  54.      * @Assert\NotBlank()
  55.      * @Assert\Length(max="25")
  56.      * @Groups({
  57.      *     "AddressOrder:io",
  58.      *     "User:output",
  59.      *     "Order:output",
  60.      *     "get_order_by_user",
  61.      * })
  62.      */
  63.     private string $firstName;
  64.     /**
  65.      * @ORM\Column(type="string", length=25)
  66.      * @SerializedName("last_name")
  67.      * @Assert\NotBlank()
  68.      * @Assert\Length(max="25")
  69.      * @Groups({
  70.      *     "AddressOrder:io",
  71.      *     "User:output",
  72.      *     "Order:output",
  73.      *     "get_order_by_user",
  74.      * })
  75.      */
  76.     private string $lastName;
  77.     /**
  78.      * @ORM\Column(type="string", length=10)
  79.      * @SerializedName("phone_number")
  80.      * @Assert\NotBlank()
  81.      * @Assert\Length(max="10")
  82.      * @Groups({
  83.      *     "AddressOrder:io",
  84.      *     "User:output",
  85.      *     "Order:output",
  86.      *     "get_order_by_user",
  87.      * })
  88.      */
  89.     private string $phoneNumber;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      * @SerializedName("extra_information")
  93.      * @Groups({
  94.      *     "AddressOrder:io",
  95.      *     "User:output",
  96.      *     "Order:output",
  97.      *     "get_order_by_user",
  98.      * })
  99.      */
  100.     private ?string $extraInformation;
  101.     /**
  102.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="addressesOrder")
  103.      * @ORM\JoinColumn(nullable=false)
  104.      * @SerializedName("user")
  105.      * @Groups({
  106.      *     "AddressOrder:io",
  107.      * })
  108.      */
  109.     private $user;
  110.     /**
  111.      * @var Department
  112.      *
  113.      * @ORM\ManyToOne(targetEntity="App\Entity\Segmentation\Department", inversedBy="order")
  114.      */
  115.     private $department;
  116.     public function getUser(): ?User
  117.     {
  118.         return $this->user;
  119.     }
  120.     public function setUser(?User $user): self
  121.     {
  122.         $this->user $user;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return Department
  127.      */
  128.     public function getDepartment(): Department
  129.     {
  130.         return $this->department;
  131.     }
  132.     /**
  133.      * @param Department $department
  134.      *
  135.      * @return Address
  136.      */
  137.     public function setDepartment(Department $department): Address
  138.     {
  139.         $this->department $department;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return string
  144.      */
  145.     public function getFirstName(): string
  146.     {
  147.         return $this->firstName;
  148.     }
  149.     /**
  150.      * @param string $firstName
  151.      * @return Order
  152.      */
  153.     public function setFirstName(string $firstName): Order
  154.     {
  155.         $this->firstName $firstName;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return string
  160.      */
  161.     public function getLastName(): string
  162.     {
  163.         return $this->lastName;
  164.     }
  165.     /**
  166.      * @param string $lastName
  167.      * @return Order
  168.      */
  169.     public function setLastName(string $lastName): Order
  170.     {
  171.         $this->lastName $lastName;
  172.         return $this;
  173.     }
  174.     /**
  175.      * @return string
  176.      */
  177.     public function getPhoneNumber(): string
  178.     {
  179.         return $this->phoneNumber;
  180.     }
  181.     /**
  182.      * @param string $phoneNumber
  183.      * @return Order
  184.      */
  185.     public function setPhoneNumber(string $phoneNumber): Order
  186.     {
  187.         $this->phoneNumber $phoneNumber;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return string
  192.      */
  193.     public function getExtraInformation(): ?string
  194.     {
  195.         return $this->extraInformation;
  196.     }
  197.     /**
  198.      * @param string|null $extraInformation
  199.      * @return Order
  200.      */
  201.     public function setExtraInformation(?string $extraInformation): Order
  202.     {
  203.         $this->extraInformation $extraInformation;
  204.         return $this;
  205.     }
  206. }