|
|
@@ -0,0 +1,88 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+
|
|
|
+namespace App\Entity\Booking;
|
|
|
+
|
|
|
+use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
+use App\Annotation\OrganizationDefaultValue;
|
|
|
+use App\Annotation\YearConstraintAware;
|
|
|
+use App\Entity\Organization\Organization;
|
|
|
+use App\Entity\Traits\ActivityYearTrait;
|
|
|
+use App\Repository\Booking\CourseRepository;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Course, et supprimer l'attribut discr.
|
|
|
+ *
|
|
|
+ * Classe Course qui permet de gérer les cours de la structure.
|
|
|
+ */
|
|
|
+#[ApiResource(
|
|
|
+ collectionOperations:[
|
|
|
+ 'get'
|
|
|
+ ],
|
|
|
+ itemOperations: [
|
|
|
+ "get" => ["security" => "is_granted('ROLE_COURSE_VIEW') and object.getOrganization().getId() == user.getOrganization().getId()"],
|
|
|
+ ]
|
|
|
+)]
|
|
|
+#[ORM\Entity(repositoryClass:CourseRepository::class)]
|
|
|
+#[YearConstraintAware(startYearFieldName: "startYear", endYearFieldName: "endYear")]
|
|
|
+#[OrganizationDefaultValue(fieldName: "organization")]
|
|
|
+
|
|
|
+#[ORM\Table(name: 'Booking')]
|
|
|
+class Course
|
|
|
+{
|
|
|
+ use ActivityYearTrait;
|
|
|
+
|
|
|
+ #[ORM\Id]
|
|
|
+ #[ORM\Column]
|
|
|
+ #[ORM\GeneratedValue]
|
|
|
+ private ?int $id = null;
|
|
|
+
|
|
|
+ #[ORM\Column(length: 255, nullable: false)]
|
|
|
+ private string $discr = 'course';
|
|
|
+
|
|
|
+ #[ORM\ManyToOne(inversedBy: 'organizationAddressPostals')]
|
|
|
+ #[ORM\JoinColumn(nullable: false)]
|
|
|
+ private Organization $organization;
|
|
|
+
|
|
|
+ #[ORM\Column(type: 'datetime', nullable: true)]
|
|
|
+ private ?\DateTimeInterface $datetimeStart = null;
|
|
|
+
|
|
|
+ #[ORM\Column(type: 'datetime', nullable: true)]
|
|
|
+ private ?\DateTimeInterface $datetimeEnd = null;
|
|
|
+
|
|
|
+ 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 getDatetimeStart(): ?\DateTimeInterface {
|
|
|
+ return $this->datetimeStart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDatetimeStart(?\DateTimeInterface $datetimeStart = null): self {
|
|
|
+ $this->datetimeStart = $datetimeStart;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDatetimeEnd(): ?\DateTimeInterface {
|
|
|
+ return $this->datetimeEnd;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDatetimeEnd(?\DateTimeInterface $datetimeEnd = null) :self {
|
|
|
+ $this->datetimeEnd = $datetimeEnd;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+}
|