| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- declare (strict_types=1);
- namespace App\Entity\Booking;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Access\Access;
- use App\Entity\Organization\Organization;
- //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Classe ... qui ...
- */
- #[ApiResource(
- operations: [
- new Get(
- security: 'is_granted(\'ROLE_ADMIN\') and object.getOrganization().getId() == user.getOrganization().getId()'
- )
- ]
- )]
- //#[Auditable]
- #[ORM\Entity]
- class Attendance
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\ManyToOne(inversedBy: 'attendances')]
- private Organization $organization;
- #[ORM\ManyToOne(inversedBy: 'attendances')]
- private Access $access;
- #[ORM\ManyToOne(inversedBy: 'attendanceReplacements')]
- private Access $replacement;
- #[ORM\OneToMany(mappedBy: 'attendance', targetEntity: AttendanceBooking::class, cascade: ['persist'], orphanRemoval: true)]
- #[ORM\JoinColumn(nullable: false)]
- private Collection $attendanceBooking;
- public function __construct()
- {
- $this->attendanceBooking = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getOrganization(): ?Organization
- {
- return $this->organization;
- }
- public function setOrganization(?Organization $organization): self
- {
- $this->organization = $organization;
- return $this;
- }
- public function getAccess(): ?Access
- {
- return $this->access;
- }
- public function setAccess(?Access $access): self
- {
- $this->access = $access;
- return $this;
- }
- public function getReplacement(): ?Access
- {
- return $this->replacement;
- }
- public function setReplacement(?Access $replacement): self
- {
- $this->replacement = $replacement;
- return $this;
- }
- /**
- * @return Collection<int, AttendanceBooking>
- */
- public function getAttendanceBooking(): Collection
- {
- return $this->attendanceBooking;
- }
- public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
- {
- if (!$this->attendanceBooking->contains($attendanceBooking)) {
- $this->attendanceBooking[] = $attendanceBooking;
- $attendanceBooking->setAttendance($this);
- }
- return $this;
- }
- public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
- {
- if ($this->attendanceBooking->removeElement($attendanceBooking)) {
- // set the owning side to null (unless already changed)
- if ($attendanceBooking->getAttendance() === $this) {
- $attendanceBooking->setAttendance(null);
- }
- }
- return $this;
- }
- }
|