src/Entity/AccountAddress.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\AccountAddressRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. #[ORM\Entity(repositoryClassAccountAddressRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['account_address:read']],
  15.     denormalizationContext: ['groups' => ['account_address:write']],
  16.     order: ['id' => 'DESC'],
  17. )]
  18. #[ApiFilter(SearchFilter::class, properties: [
  19.     'name' => 'ipartial'
  20.     'account' => 'exact'
  21. ])]
  22. class AccountAddress
  23. {
  24.     #[Groups(['account_address:read''account_address:write''account:read''order:read''pre_order:read','agreements:read'])]
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     private ?int $id null;
  29.     #[Groups(['account_address:read''account_address:write''account:read''order:read''pre_order:read','agreements:read'])]
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $name null;
  32.     #[Groups(['account_address:read''account_address:write''account:read''order:read''pre_order:read','agreements:read'])]
  33.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  34.     private ?string $description null;
  35.     #[Groups(['account_address:read''account_address:write'])]
  36.     #[ORM\ManyToOne(inversedBy'accountAddresses')]
  37.     private ?Accounts $account null;
  38.     #[Groups(['account_address:read''account_address:write''account:read''order:read''pre_order:read','agreements:read'])]
  39.     #[ORM\Column(length100nullabletrue)]
  40.     private ?string $code1c null;
  41.     #[Groups(['account_address:read''account_address:write'])]
  42.     #[ORM\OneToMany(mappedBy'address'targetEntityOrders::class)]
  43.     private Collection $orders;
  44.     #[Groups(['account_address:read''account_address:write'])]
  45.     #[ORM\OneToMany(mappedBy'address'targetEntityPreOrder::class)]
  46.     private Collection $preOrders;
  47.     public function __construct()
  48.     {
  49.         $this->orders = new ArrayCollection();
  50.         $this->preOrders = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getName(): ?string
  57.     {
  58.         return $this->name;
  59.     }
  60.     public function setName(?string $name): self
  61.     {
  62.         $this->name $name;
  63.         return $this;
  64.     }
  65.     public function getDescription(): ?string
  66.     {
  67.         return $this->description;
  68.     }
  69.     public function setDescription(?string $description): self
  70.     {
  71.         $this->description $description;
  72.         return $this;
  73.     }
  74.     public function getAccount(): ?Accounts
  75.     {
  76.         return $this->account;
  77.     }
  78.     public function setAccount(?Accounts $account): self
  79.     {
  80.         $this->account $account;
  81.         return $this;
  82.     }
  83.     public function getCode1c(): ?string
  84.     {
  85.         return $this->code1c;
  86.     }
  87.     public function setCode1c(?string $code1c): self
  88.     {
  89.         $this->code1c $code1c;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection<int, Orders>
  94.      */
  95.     public function getOrders(): Collection
  96.     {
  97.         return $this->orders;
  98.     }
  99.     public function addOrder(Orders $order): self
  100.     {
  101.         if (!$this->orders->contains($order)) {
  102.             $this->orders->add($order);
  103.             $order->setAddress($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeOrder(Orders $order): self
  108.     {
  109.         if ($this->orders->removeElement($order)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($order->getAddress() === $this) {
  112.                 $order->setAddress(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return Collection<int, PreOrder>
  119.      */
  120.     public function getPreOrders(): Collection
  121.     {
  122.         return $this->preOrders;
  123.     }
  124.     public function addPreOrder(PreOrder $preOrder): self
  125.     {
  126.         if (!$this->preOrders->contains($preOrder)) {
  127.             $this->preOrders->add($preOrder);
  128.             $preOrder->setAddress($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removePreOrder(PreOrder $preOrder): self
  133.     {
  134.         if ($this->preOrders->removeElement($preOrder)) {
  135.             // set the owning side to null (unless already changed)
  136.             if ($preOrder->getAddress() === $this) {
  137.                 $preOrder->setAddress(null);
  138.             }
  139.         }
  140.         return $this;
  141.     }
  142. }