| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Billing;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\Delete;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\GetCollection;
- use ApiPlatform\Metadata\Post;
- use ApiPlatform\Metadata\Put;
- use App\Attribute\BillingSettingDefaultValue;
- use App\Entity\Product\IntangibleDiscountDetail;
- use App\Repository\Billing\ResidenceAreaRepository;
- use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Zone de résidence d'un Access, telle que définie par l'Organization.
- *
- * Security :
- *
- * @see \App\Doctrine\Billing\CurrentResidenceAreaExtension
- */
- #[ApiResource(
- operations: [
- new Get(
- security: 'is_granted(\'ROLE_ORGANIZATION_VIEW\') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()'
- ),
- new Put(
- security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()'
- ),
- new Delete(
- security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()'
- ),
- new GetCollection(
- security: 'is_granted(\'ROLE_ORGANIZATION\')'
- ),
- new Post(
- security: 'is_granted(\'ROLE_ORGANIZATION\')'
- ),
- ]
- )]
- #[Auditable]
- #[BillingSettingDefaultValue(fieldName: 'billingSetting')]
- #[ORM\Entity(repositoryClass: ResidenceAreaRepository::class)]
- class ResidenceArea
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\ManyToOne(targetEntity: BillingSetting::class, inversedBy: 'residenceAreas')]
- #[ORM\JoinColumn(nullable: false)]
- private BillingSetting $billingSetting;
- /** @var Collection<int, AccessBilling> */
- #[ORM\OneToMany(targetEntity: AccessBilling::class, mappedBy: 'residenceArea')]
- private Collection $accessBilling;
- /** @var Collection<int, IntangibleDiscountDetail> */
- #[ORM\OneToMany(targetEntity: IntangibleDiscountDetail::class, mappedBy: 'residenceArea')]
- private Collection $intangibleDiscountDetails;
- #[ORM\Column(length: 255)]
- private string $label;
- public function __construct()
- {
- $this->accessBilling = new ArrayCollection();
- $this->intangibleDiscountDetails = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getLabel(): string
- {
- return $this->label;
- }
- public function setLabel(string $label): self
- {
- $this->label = $label;
- return $this;
- }
- public function getBillingSetting(): ?BillingSetting
- {
- return $this->billingSetting;
- }
- public function setBillingSetting(?BillingSetting $billingSetting): self
- {
- $this->billingSetting = $billingSetting;
- return $this;
- }
- /**
- * @return Collection<int, AccessBilling>
- */
- public function getAccessBilling(): Collection
- {
- return $this->accessBilling;
- }
- public function addAccessBilling(AccessBilling $accessBilling): self
- {
- if (!$this->accessBilling->contains($accessBilling)) {
- $this->accessBilling[] = $accessBilling;
- $accessBilling->setResidenceArea($this);
- }
- return $this;
- }
- public function removeAccessBilling(AccessBilling $accessBilling): self
- {
- if ($this->accessBilling->removeElement($accessBilling)) {
- // set the owning side to null (unless already changed)
- if ($accessBilling->getResidenceArea() === $this) {
- $accessBilling->setResidenceArea(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, IntangibleDiscountDetail>
- */
- public function getIntangibleDiscountDetails(): Collection
- {
- return $this->intangibleDiscountDetails;
- }
- public function addIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
- {
- if (!$this->intangibleDiscountDetails->contains($intangibleDiscountDetail)) {
- $this->intangibleDiscountDetails[] = $intangibleDiscountDetail;
- $intangibleDiscountDetail->setResidenceArea($this);
- }
- return $this;
- }
- public function removeIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
- {
- if ($this->intangibleDiscountDetails->removeElement($intangibleDiscountDetail)) {
- // set the owning side to null (unless already changed)
- if ($intangibleDiscountDetail->getResidenceArea() === $this) {
- $intangibleDiscountDetail->setResidenceArea(null);
- }
- }
- return $this;
- }
- }
|