|
|
@@ -3,46 +3,67 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace App\Entity\Core;
|
|
|
|
|
|
+use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
use App\Entity\Organization\OrganizationAddressPostal;
|
|
|
use App\Repository\Core\AddressPostalRepository;
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
-
|
|
|
+use App\Entity\Person\PersonAddressPostal;
|
|
|
+use Symfony\Component\Serializer\Annotation\Groups;
|
|
|
+
|
|
|
+#[ApiResource(
|
|
|
+ collectionOperations: [
|
|
|
+ "get"
|
|
|
+ ],
|
|
|
+ itemOperations: [
|
|
|
+ "get" => ["security" => "is_granted('ROLE_ORGANIZATION_VIEW') and object.getOrganizationAddressPostal().getOrganization().getId() == user.getOrganization().getId()"],
|
|
|
+ ]
|
|
|
+)]
|
|
|
#[ORM\Entity(repositoryClass: AddressPostalRepository::class)]
|
|
|
class AddressPostal
|
|
|
{
|
|
|
#[ORM\Id]
|
|
|
#[ORM\Column]
|
|
|
#[ORM\GeneratedValue]
|
|
|
+ #[Groups(["address", "access_address"])]
|
|
|
private ?int $id = null;
|
|
|
|
|
|
#[ORM\ManyToOne]
|
|
|
+ #[Groups("address")]
|
|
|
private ?Country $addressCountry = null;
|
|
|
|
|
|
#[ORM\Column(length: 100, nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?string $addressCity = null;
|
|
|
|
|
|
#[ORM\Column(length: 100, nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?string $addressOwner = null;
|
|
|
|
|
|
#[ORM\Column(length: 20, nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?string $postalCode = null;
|
|
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?string $streetAddress = null;
|
|
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?string $streetAddressSecond = null;
|
|
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?string $streetAddressThird = null;
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?float $latitude = null;
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
+ #[Groups("address")]
|
|
|
private ?float $longitude = null;
|
|
|
|
|
|
- #[ORM\OneToOne(mappedBy: 'addressPostal', cascade: ['persist', 'remove'])]
|
|
|
+ #[ORM\OneToOne(mappedBy: 'addressPostal')]
|
|
|
private OrganizationAddressPostal $organizationAddressPostal;
|
|
|
|
|
|
public function getId(): ?int
|
|
|
@@ -165,13 +186,20 @@ class AddressPostal
|
|
|
|
|
|
public function setOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
|
|
|
{
|
|
|
- // set the owning side of the relation if necessary
|
|
|
- if ($organizationAddressPostal->getAddressPostal() !== $this) {
|
|
|
- $organizationAddressPostal->setAddressPostal($this);
|
|
|
- }
|
|
|
-
|
|
|
$this->organizationAddressPostal = $organizationAddressPostal;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
+
|
|
|
+ public function getPersonAddressPostal(): ?PersonAddressPostal
|
|
|
+ {
|
|
|
+ return $this->personAddressPostal;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setPersonAddressPostal(PersonAddressPostal $personAddressPostal): self
|
|
|
+ {
|
|
|
+ $this->personAddressPostal = $personAddressPostal;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
}
|