<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\PropertyAddressRepository;
use ApiPlatform\Core\Action\NotFoundAction;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* security= "is_granted('ROLE_AGENT')",
* normalizationContext={"groups"={"property-address:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"property-address:write"}, "swagger_definition_name"="Write","skip_null_values" = true},
* itemOperations={
* "get"={
* "path"="/property/address/{id}",
* "controller"=NotFoundAction::class,
* "read"=false,
* "output"=false,
* },
* },
* collectionOperations={
* "get"={
* "path"="/property/address",
* "controller"=NotFoundAction::class,
* "read"=false,
* "output"=false,
* },
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* }
* )
* @ORM\Entity(repositoryClass=PropertyAddressRepository::class)
*/
class PropertyAddress
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "transaction-item:read",
* "mandate:read",
* "milkiya:read",
* "business-indication:item:read",
* })
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Groups({
* "property:read","property:write","property:put",
* "transaction-item:read",
* "mandate:read",
* "property-visit:read",
* "milkiya:read",
* "business-indication:item:read",
*
* })
*/
private ?string $firstAddress;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Groups({
* "property:read","property:write","property:put",
* "transaction-item:read",
* "mandate:read",
* "property-visit:read",
* "milkiya:read",
* "business-indication:item:read",
* })
*/
private ?string $secondAddress;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Groups({
* "property:read","property:write","property:put",
* "transaction-item:read",
* "mandate:read",
* "property-visit:read",
* "milkiya:read",
* "business-indication:item:read",
* })
*/
private ?string $zipCode;
/**
* @ORM\ManyToOne(targetEntity=City::class, inversedBy="propertyAddresses")
* @ORM\JoinColumn(nullable=false)
*
* @Groups({
* "property:read","property:write","property:put",
* "transaction-item:read",
* "mandate:read",
* "property-visit:read",
* "milkiya:read",
* "business-indication:item:read",
* "contact:read"
* })
*/
private ?City $city;
/**
* @ORM\OneToOne(targetEntity=Property::class, mappedBy="propertyAddress", cascade={"persist", "remove"})
*/
private ?Property $property;
/**
* @ORM\ManyToOne(targetEntity=Neighborhood::class, inversedBy="propertyAddresses")
* @ORM\JoinColumn(nullable=true)
* @Groups({
* "property:read","property:write","property:put",
* "mandate:read",
* })
*/
private ?Neighborhood $neighborhood;
public function getId(): ?int
{
return $this->id;
}
public function getFirstAddress(): ?string
{
return $this->firstAddress;
}
public function setFirstAddress(?string $firstAddress): self
{
$this->firstAddress = $firstAddress;
return $this;
}
public function getSecondAddress(): ?string
{
return $this->secondAddress;
}
public function setSecondAddress(?string $secondAddress): self
{
$this->secondAddress = $secondAddress;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(?string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getProperty(): ?Property
{
return $this->property;
}
public function setProperty(Property $property): self
{
// set the owning side of the relation if necessary
if ($property->getPropertyAddress() !== $this) {
$property->setPropertyAddress($this);
}
$this->property = $property;
return $this;
}
public function getNeighborhood(): ?Neighborhood
{
return $this->neighborhood;
}
public function setNeighborhood(?Neighborhood $neighborhood): self
{
$this->neighborhood = $neighborhood;
return $this;
}
}