src/Entity/PropertyAddress.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\PropertyAddressRepository;
  5. use ApiPlatform\Core\Action\NotFoundAction;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ApiResource(
  10.  *     security= "is_granted('ROLE_AGENT')",
  11.  *     normalizationContext={"groups"={"property-address:read"}, "swagger_definition_name"="Read"},
  12.  *     denormalizationContext={"groups"={"property-address:write"}, "swagger_definition_name"="Write","skip_null_values" = true},
  13.  *     itemOperations={
  14.  *         "get"={
  15.  *             "path"="/property/address/{id}",
  16.  *             "controller"=NotFoundAction::class,
  17.  *             "read"=false,
  18.  *             "output"=false,
  19.  *         },
  20.  *     },
  21.  *     collectionOperations={
  22.  *         "get"={
  23.  *             "path"="/property/address",
  24.  *             "controller"=NotFoundAction::class,
  25.  *             "read"=false,
  26.  *             "output"=false,
  27.  *         },
  28.  *     },
  29.  *     attributes={
  30.  *          "pagination_items_per_page"=10,
  31.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  32.  *     }
  33.  * )
  34.  * @ORM\Entity(repositoryClass=PropertyAddressRepository::class)
  35.  */
  36. class PropertyAddress
  37. {
  38.     /**
  39.      * @ORM\Id
  40.      * @ORM\GeneratedValue
  41.      * @ORM\Column(type="integer")
  42.      *
  43.      * @Groups({
  44.      *   "property:read",
  45.      *   "transaction-item:read",
  46.      *   "mandate:read",
  47.      *   "milkiya:read",
  48.      *   "business-indication:item:read",
  49.      * })
  50.      */
  51.     private $id;
  52.     /**
  53.      * @ORM\Column(type="text", nullable=true)
  54.      *
  55.      * @Groups({
  56.      *    "property:read","property:write","property:put",
  57.      *    "transaction-item:read",
  58.      *    "mandate:read",
  59.      *    "property-visit:read",
  60.      *    "milkiya:read",
  61.      *    "business-indication:item:read",
  62.      *
  63.      * })
  64.      */
  65.     private ?string $firstAddress;
  66.     /**
  67.      * @ORM\Column(type="text", nullable=true)
  68.      *
  69.      * @Groups({
  70.      *    "property:read","property:write","property:put",
  71.      *    "transaction-item:read",
  72.      *    "mandate:read",
  73.      *    "property-visit:read",
  74.      *    "milkiya:read",
  75.      *    "business-indication:item:read",
  76.      * })
  77.      */
  78.     private ?string $secondAddress;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      *
  82.      * @Groups({
  83.      *    "property:read","property:write","property:put",
  84.      *    "transaction-item:read",
  85.      *    "mandate:read",
  86.      *    "property-visit:read",
  87.      *    "milkiya:read",
  88.      *    "business-indication:item:read",
  89.      * })
  90.      */
  91.     private ?string $zipCode;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity=City::class, inversedBy="propertyAddresses")
  94.      * @ORM\JoinColumn(nullable=false)
  95.      *
  96.      * @Groups({
  97.      *    "property:read","property:write","property:put",
  98.      *    "transaction-item:read",
  99.      *    "mandate:read",
  100.      *    "property-visit:read",
  101.      *    "milkiya:read",
  102.      *    "business-indication:item:read",
  103.      *    "contact:read"
  104.      * })
  105.      */
  106.     private ?City $city;
  107.     /**
  108.      * @ORM\OneToOne(targetEntity=Property::class, mappedBy="propertyAddress", cascade={"persist", "remove"})
  109.      */
  110.     private ?Property $property;
  111.     /**
  112.      * @ORM\ManyToOne(targetEntity=Neighborhood::class, inversedBy="propertyAddresses")
  113.      * @ORM\JoinColumn(nullable=true)
  114.      * @Groups({
  115.      *    "property:read","property:write","property:put",
  116.      *    "mandate:read",
  117.      * })
  118.      */
  119.     private ?Neighborhood $neighborhood;
  120.     public function getId(): ?int
  121.     {
  122.         return $this->id;
  123.     }
  124.     public function getFirstAddress(): ?string
  125.     {
  126.         return $this->firstAddress;
  127.     }
  128.     public function setFirstAddress(?string $firstAddress): self
  129.     {
  130.         $this->firstAddress $firstAddress;
  131.         return $this;
  132.     }
  133.     public function getSecondAddress(): ?string
  134.     {
  135.         return $this->secondAddress;
  136.     }
  137.     public function setSecondAddress(?string $secondAddress): self
  138.     {
  139.         $this->secondAddress $secondAddress;
  140.         return $this;
  141.     }
  142.     public function getZipCode(): ?string
  143.     {
  144.         return $this->zipCode;
  145.     }
  146.     public function setZipCode(?string $zipCode): self
  147.     {
  148.         $this->zipCode $zipCode;
  149.         return $this;
  150.     }
  151.     public function getCity(): ?City
  152.     {
  153.         return $this->city;
  154.     }
  155.     public function setCity(?City $city): self
  156.     {
  157.         $this->city $city;
  158.         return $this;
  159.     }
  160.     public function getProperty(): ?Property
  161.     {
  162.         return $this->property;
  163.     }
  164.     public function setProperty(Property $property): self
  165.     {
  166.         // set the owning side of the relation if necessary
  167.         if ($property->getPropertyAddress() !== $this) {
  168.             $property->setPropertyAddress($this);
  169.         }
  170.         $this->property $property;
  171.         return $this;
  172.     }
  173.     public function getNeighborhood(): ?Neighborhood
  174.     {
  175.         return $this->neighborhood;
  176.     }
  177.     public function setNeighborhood(?Neighborhood $neighborhood): self
  178.     {
  179.         $this->neighborhood $neighborhood;
  180.         return $this;
  181.     }
  182. }