src/Entity/InterestActivity.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InterestActivityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassInterestActivityRepository::class)]
  9. #[ORM\Table(name'interest_activity')]
  10. #[ORM\Index(name'IDX_INTEREST_ACTIVITY_CATEGORY'columns: ['category'])]
  11. #[ORM\Index(name'IDX_INTEREST_ACTIVITY_CITY'columns: ['city'])]
  12. #[ORM\Index(name'IDX_INTEREST_ACTIVITY_STATUS_START'columns: ['status''start_at'])]
  13. class InterestActivity
  14. {
  15.     public const STATUS_OPEN 'open';
  16.     public const STATUS_CLOSED 'closed';
  17.     public const STATUS_CANCELED 'canceled';
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     #[ORM\ManyToOne]
  23.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  24.     private ?User $organizer null;
  25.     #[ORM\OneToOne]
  26.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL'uniquetrue)]
  27.     private ?Conversation $conversation null;
  28.     #[ORM\Column(length140)]
  29.     private string $title '';
  30.     #[ORM\Column(length80)]
  31.     private string $category '';
  32.     #[ORM\Column(length120)]
  33.     private string $city '';
  34.     #[ORM\Column(typeTypes::TEXT)]
  35.     private string $description '';
  36.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  37.     private ?\DateTimeImmutable $startAt null;
  38.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  39.     private ?\DateTimeImmutable $endAt null;
  40.     #[ORM\Column]
  41.     private int $capacity 20;
  42.     #[ORM\Column(length20)]
  43.     private string $status self::STATUS_OPEN;
  44.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  45.     private ?\DateTimeImmutable $createdAt null;
  46.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  47.     private ?\DateTimeImmutable $updatedAt null;
  48.     /**
  49.      * @var Collection<int, InterestActivityRegistration>
  50.      */
  51.     #[ORM\OneToMany(mappedBy'activity'targetEntityInterestActivityRegistration::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  52.     private Collection $registrations;
  53.     public function __construct()
  54.     {
  55.         $this->registrations = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getOrganizer(): ?User
  62.     {
  63.         return $this->organizer;
  64.     }
  65.     public function setOrganizer(?User $organizer): self
  66.     {
  67.         $this->organizer $organizer;
  68.         return $this;
  69.     }
  70.     public function getConversation(): ?Conversation
  71.     {
  72.         return $this->conversation;
  73.     }
  74.     public function setConversation(?Conversation $conversation): self
  75.     {
  76.         $this->conversation $conversation;
  77.         return $this;
  78.     }
  79.     public function getTitle(): string
  80.     {
  81.         return $this->title;
  82.     }
  83.     public function setTitle(string $title): self
  84.     {
  85.         $this->title mb_substr(trim($title), 0140);
  86.         return $this;
  87.     }
  88.     public function getCategory(): string
  89.     {
  90.         return $this->category;
  91.     }
  92.     public function setCategory(string $category): self
  93.     {
  94.         $this->category mb_substr(trim($category), 080);
  95.         return $this;
  96.     }
  97.     public function getCity(): string
  98.     {
  99.         return $this->city;
  100.     }
  101.     public function setCity(string $city): self
  102.     {
  103.         $this->city mb_substr(trim($city), 0120);
  104.         return $this;
  105.     }
  106.     public function getDescription(): string
  107.     {
  108.         return $this->description;
  109.     }
  110.     public function setDescription(string $description): self
  111.     {
  112.         $this->description mb_substr(trim($description), 05000);
  113.         return $this;
  114.     }
  115.     public function getStartAt(): ?\DateTimeImmutable
  116.     {
  117.         return $this->startAt;
  118.     }
  119.     public function setStartAt(?\DateTimeImmutable $startAt): self
  120.     {
  121.         $this->startAt $startAt;
  122.         return $this;
  123.     }
  124.     public function getEndAt(): ?\DateTimeImmutable
  125.     {
  126.         return $this->endAt;
  127.     }
  128.     public function setEndAt(?\DateTimeImmutable $endAt): self
  129.     {
  130.         $this->endAt $endAt;
  131.         return $this;
  132.     }
  133.     public function getCapacity(): int
  134.     {
  135.         return $this->capacity;
  136.     }
  137.     public function setCapacity(int $capacity): self
  138.     {
  139.         $this->capacity max(2min(300$capacity));
  140.         return $this;
  141.     }
  142.     public function getStatus(): string
  143.     {
  144.         return $this->status;
  145.     }
  146.     public function setStatus(string $status): self
  147.     {
  148.         $this->status $status;
  149.         return $this;
  150.     }
  151.     public function getCreatedAt(): ?\DateTimeImmutable
  152.     {
  153.         return $this->createdAt;
  154.     }
  155.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  156.     {
  157.         $this->createdAt $createdAt;
  158.         return $this;
  159.     }
  160.     public function getUpdatedAt(): ?\DateTimeImmutable
  161.     {
  162.         return $this->updatedAt;
  163.     }
  164.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  165.     {
  166.         $this->updatedAt $updatedAt;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, InterestActivityRegistration>
  171.      */
  172.     public function getRegistrations(): Collection
  173.     {
  174.         return $this->registrations;
  175.     }
  176. }