src/Entity/User/Address/Home.php line 56

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\HomeRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Serializer\Annotation\SerializedName;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Entity(repositoryClass=HomeRepository::class)
  13.  * @ApiResource(
  14.  *     shortName="address-home",
  15.  *     attributes={
  16.  *          "normalization_context"={
  17.  *              "groups"={
  18.  *                  "AddressHome:output",
  19.  *                  "AddressHome:io",
  20.  *               }
  21.  *          },
  22.  *          "denormalization_context"={
  23.  *              "groups"={
  24.  *                  "AddressHome:input",
  25.  *                  "AddressHome:io",
  26.  *              }
  27.  *          }
  28.  *      },
  29.  *     collectionOperations={
  30.  *          "post"={
  31.  *              "method"="POST",
  32.  *              "access_control"="is_granted('ROLE_USER')"
  33.  *          },
  34.  *          "get"={
  35.  *              "method"="GET",
  36.  *              "access_control"="is_granted('ROLE_USER')",
  37.  *          },
  38.  *     },
  39.  *     itemOperations={
  40.  *          "get"={
  41.  *              "method"="GET",
  42.  *              "access_control"="is_granted('ROLE_USER')",
  43.  *          },
  44.  *          "put"={
  45.  *              "method"="PUT",
  46.  *              "access_control"="is_granted('ROLE_USER')",
  47.  *              "validation_groups"={"put_address_home"}
  48.  *          },
  49.  *     },
  50.  * )
  51.  */
  52. class Home extends Address
  53. {
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="addressesHome")
  56.      * @ORM\JoinColumn(nullable=false)
  57.      * @SerializedName("user")
  58.      * @Groups({
  59.      *     "AddressHome:io",
  60.      * })
  61.      */
  62.     private $user;
  63.     /**
  64.      * @var Department
  65.      *
  66.      * @ORM\ManyToOne(targetEntity="App\Entity\Segmentation\Department", inversedBy="address")
  67.      */
  68.     private $department;
  69.     /**
  70.      * @ORM\Column(type="string", length=10, nullable=true)
  71.      * @SerializedName("phone_number")
  72.      * @Assert\Length(max="10")
  73.      * @Groups({
  74.      *     "AddressHome:io",
  75.      *     "User:io",
  76.      * })
  77.      */
  78.     private ?string $phoneNumber null;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      * @SerializedName("extra_information")
  82.      * @Groups({
  83.      *     "AddressHome:io",
  84.      *     "User:io",
  85.      * })
  86.      */
  87.     private ?string $extraInformation null;
  88.     public function getUser(): ?User
  89.     {
  90.         return $this->user;
  91.     }
  92.     public function setUser(?User $user): self
  93.     {
  94.         $this->user $user;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Department
  99.      */
  100.     public function getDepartment(): Department
  101.     {
  102.         return $this->department;
  103.     }
  104.     /**
  105.      * @param Department $department
  106.      *
  107.      * @return Address
  108.      */
  109.     public function setDepartment(Department $department): Address
  110.     {
  111.         $this->department $department;
  112.         return $this;
  113.     }
  114.     public function getPhoneNumber(): ?string
  115.     {
  116.         return $this->phoneNumber;
  117.     }
  118.     public function setPhoneNumber(?string $phoneNumber): self
  119.     {
  120.         $this->phoneNumber $phoneNumber;
  121.         return $this;
  122.     }
  123.     public function getExtraInformation(): ?string
  124.     {
  125.         return $this->extraInformation;
  126.     }
  127.     public function setExtraInformation(?string $extraInformation): self
  128.     {
  129.         $this->extraInformation $extraInformation;
  130.         return $this;
  131.     }
  132. }