src/Entity/Places/Address.php line 22

  1. <?php
  2. namespace App\Entity\Places;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Link;
  6. use App\Entity\Common\Company;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity]
  11. #[ApiResource(routePrefix'/places')]
  12. #[ApiResource(
  13.     uriTemplate'/companies/{slug}/addresses',
  14.     operations: [new GetCollection()],
  15.     uriVariables: [
  16.         'slug' => new Link(fromProperty'addresses'fromClassCompany::class),
  17.     ],
  18. )]
  19. class Address extends Facility
  20. {
  21.     #[Assert\Type(typeTypes::BOOLEAN)]
  22.     #[ORM\Column(name'is_main'typeTypes::BOOLEANoptions: ['default' => false])]
  23.     private bool $main false;
  24.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'addresses')]
  25.     #[ORM\JoinColumn(name'owner_id')]
  26.     private ?Company $owner null;
  27.     public function isMain(): bool
  28.     {
  29.         return $this->main;
  30.     }
  31.     public function setMain(bool $main): static
  32.     {
  33.         $this->main $main;
  34.         return $this;
  35.     }
  36.     public function getOwner(): ?Company
  37.     {
  38.         return $this->owner;
  39.     }
  40.     public function setOwner(?Company $owner): static
  41.     {
  42.         $this->owner $owner;
  43.         return $this;
  44.     }
  45. }