src/Entity/Company.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use ApiPlatform\Metadata\ApiResource;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\Delete;
  11. use ApiPlatform\Metadata\Post;
  12. use ApiPlatform\Metadata\Patch;
  13. use ApiPlatform\Metadata\Put;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. #[ORM\Entity(repositoryClassCompanyRepository::class)]
  16. #[ApiResource(
  17.     normalizationContext: ['groups' => ['company:read']],
  18.     denormalizationContext: ['groups' => ['company:write']],
  19.     operations: [
  20.         new Get(),
  21.         new Put(security'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
  22.         new Patch(security'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
  23.         new Delete(security'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
  24.         new GetCollection(),
  25.         new Post(security'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")')
  26.     ],
  27.     paginationEnabledfalse
  28. )]
  29. class Company
  30. {
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read'])]
  35.     private ?int $id null;
  36.     
  37.     #[ORM\Column(length255)]
  38.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read''company:write'])]
  39.     private ?string $name null;
  40.     #[ORM\Column(length255)]
  41.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read''company:write'])]
  42.     private ?string $address null;
  43.     #[ORM\Column(length10)]
  44.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read''company:write'])]
  45.     private ?string $currency null;
  46.     #[ORM\Column(length255)]
  47.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read''company:write'])]
  48.     private ?string $ice null;
  49.     #[ORM\Column(length255)]
  50.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read''company:write'])]
  51.     private ?string $email null;
  52.     #[ORM\Column(length255)]
  53.     #[Groups(['generalInvoice:read''invoice:read''invoiceDetail:read''company:read''company:write'])]
  54.     private ?string $phone null;
  55.     #[ORM\OneToMany(mappedBy'company'targetEntityInvoice::class)]
  56.     private Collection $invoices;
  57.     #[ORM\OneToMany(mappedBy'biller'targetEntityGeneralInvoice::class)]
  58.     private Collection $generalInvoices;
  59.     #[ORM\Column(length255nullabletrue)]
  60.     #[Groups(['invoice:read''invoiceDetail:read''company:read''company:write'])]
  61.     private ?string $rc null;
  62.     #[ORM\Column(length255nullabletrue)]
  63.     #[Groups(['invoice:read''invoiceDetail:read''company:read''company:write'])]
  64.     private ?string $pat null;
  65.     #[ORM\Column(length255nullabletrue)]
  66.     #[Groups(['invoice:read''invoiceDetail:read''company:read''company:write'])]
  67.     private ?string $i_f null;
  68.     public function __construct()
  69.     {
  70.         $this->invoices = new ArrayCollection();
  71.         $this->generalInvoices = new ArrayCollection();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getName(): ?string
  78.     {
  79.         return $this->name;
  80.     }
  81.     public function setName(string $name): self
  82.     {
  83.         $this->name $name;
  84.         return $this;
  85.     }
  86.     public function getAddress(): ?string
  87.     {
  88.         return $this->address;
  89.     }
  90.     public function setAddress(string $address): self
  91.     {
  92.         $this->address $address;
  93.         return $this;
  94.     }
  95.     public function getCurrency(): ?string
  96.     {
  97.         return $this->currency;
  98.     }
  99.     public function setCurrency(string $currency): self
  100.     {
  101.         $this->currency $currency;
  102.         return $this;
  103.     }
  104.     public function getIce(): ?string
  105.     {
  106.         return $this->ice;
  107.     }
  108.     public function setIce(string $ice): self
  109.     {
  110.         $this->ice $ice;
  111.         return $this;
  112.     }
  113.     public function getEmail(): ?string
  114.     {
  115.         return $this->email;
  116.     }
  117.     public function setEmail(string $email): self
  118.     {
  119.         $this->email $email;
  120.         return $this;
  121.     }
  122.     public function getPhone(): ?string
  123.     {
  124.         return $this->phone;
  125.     }
  126.     public function setPhone(string $phone): self
  127.     {
  128.         $this->phone $phone;
  129.         return $this;
  130.     }
  131.     /**
  132.      * @return Collection<int, Invoice>
  133.      */
  134.     public function getInvoices(): Collection
  135.     {
  136.         return $this->invoices;
  137.     }
  138.     public function addInvoice(Invoice $invoice): self
  139.     {
  140.         if (!$this->invoices->contains($invoice)) {
  141.             $this->invoices->add($invoice);
  142.             $invoice->setCompany($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeInvoice(Invoice $invoice): self
  147.     {
  148.         if ($this->invoices->removeElement($invoice)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($invoice->getCompany() === $this) {
  151.                 $invoice->setCompany(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156.     public function __toString(){
  157.         return $this->name;
  158.       }
  159.     /**
  160.      * @return Collection<int, GeneralInvoice>
  161.      */
  162.     public function getGeneralInvoices(): Collection
  163.     {
  164.         return $this->generalInvoices;
  165.     }
  166.     public function addGeneralInvoice(GeneralInvoice $generalInvoice): self
  167.     {
  168.         if (!$this->generalInvoices->contains($generalInvoice)) {
  169.             $this->generalInvoices->add($generalInvoice);
  170.             $generalInvoice->setBiller($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeGeneralInvoice(GeneralInvoice $generalInvoice): self
  175.     {
  176.         if ($this->generalInvoices->removeElement($generalInvoice)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($generalInvoice->getBiller() === $this) {
  179.                 $generalInvoice->setBiller(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     public function getRc(): ?string
  185.     {
  186.         return $this->rc;
  187.     }
  188.     public function setRc(?string $rc): self
  189.     {
  190.         $this->rc $rc;
  191.         return $this;
  192.     }
  193.     public function getPat(): ?string
  194.     {
  195.         return $this->pat;
  196.     }
  197.     public function setPat(?string $pat): self
  198.     {
  199.         $this->pat $pat;
  200.         return $this;
  201.     }
  202.     public function getIF(): ?string
  203.     {
  204.         return $this->i_f;
  205.     }
  206.     public function setIF(?string $i_f): self
  207.     {
  208.         $this->i_f $i_f;
  209.         return $this;
  210.     }
  211. }