src/Entity/Company.php line 32
<?php
namespace App\Entity;
use App\Repository\CompanyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['company:read']],
denormalizationContext: ['groups' => ['company:write']],
operations: [
new Get(),
new Put(security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
new Patch(security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
new Delete(security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
new GetCollection(),
new Post(security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")')
],
paginationEnabled: false
)]
class Company
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $name = null;
#[ORM\Column(length: 255)]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $address = null;
#[ORM\Column(length: 10)]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $currency = null;
#[ORM\Column(length: 255)]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $ice = null;
#[ORM\Column(length: 255)]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $email = null;
#[ORM\Column(length: 255)]
#[Groups(['generalInvoice:read', 'invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $phone = null;
#[ORM\OneToMany(mappedBy: 'company', targetEntity: Invoice::class)]
private Collection $invoices;
#[ORM\OneToMany(mappedBy: 'biller', targetEntity: GeneralInvoice::class)]
private Collection $generalInvoices;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $rc = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $pat = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['invoice:read', 'invoiceDetail:read', 'company:read', 'company:write'])]
private ?string $i_f = null;
public function __construct()
{
$this->invoices = new ArrayCollection();
$this->generalInvoices = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getCurrency(): ?string
{
return $this->currency;
}
public function setCurrency(string $currency): self
{
$this->currency = $currency;
return $this;
}
public function getIce(): ?string
{
return $this->ice;
}
public function setIce(string $ice): self
{
$this->ice = $ice;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setCompany($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getCompany() === $this) {
$invoice->setCompany(null);
}
}
return $this;
}
public function __toString(){
return $this->name;
}
/**
* @return Collection<int, GeneralInvoice>
*/
public function getGeneralInvoices(): Collection
{
return $this->generalInvoices;
}
public function addGeneralInvoice(GeneralInvoice $generalInvoice): self
{
if (!$this->generalInvoices->contains($generalInvoice)) {
$this->generalInvoices->add($generalInvoice);
$generalInvoice->setBiller($this);
}
return $this;
}
public function removeGeneralInvoice(GeneralInvoice $generalInvoice): self
{
if ($this->generalInvoices->removeElement($generalInvoice)) {
// set the owning side to null (unless already changed)
if ($generalInvoice->getBiller() === $this) {
$generalInvoice->setBiller(null);
}
}
return $this;
}
public function getRc(): ?string
{
return $this->rc;
}
public function setRc(?string $rc): self
{
$this->rc = $rc;
return $this;
}
public function getPat(): ?string
{
return $this->pat;
}
public function setPat(?string $pat): self
{
$this->pat = $pat;
return $this;
}
public function getIF(): ?string
{
return $this->i_f;
}
public function setIF(?string $i_f): self
{
$this->i_f = $i_f;
return $this;
}
}