src/Entity/Category.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: CategoryRepository::class)]
  8. class Category
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id = null;
  14.     #[ORM\Column(length: 255)]
  15.     private ?string $titleCategory = null;
  16.     #[ORM\Column(nullable: true, length: 255)]
  17.     private ?string $image = null;
  18.     #[ORM\Column]
  19.     protected ?bool $activity = null;
  20.     #[ORM\OneToOne(mappedBy: 'category', cascade: ['persist', 'remove'])]
  21.     private ?CategorySetting $categorySetting = null;
  22.     //#[ORM\OneToMany(mappedBy: 'categories', targetEntity: Calendar::class, orphanRemoval: true)]
  23.     //protected Collection $calendars;
  24.     #[ORM\OneToMany(mappedBy: 'category', targetEntity: Calendar::class, orphanRemoval: true)]
  25.     protected Collection $calendars;
  26.     
  27.     #[ORM\OneToMany(mappedBy: 'category', targetEntity: Activity::class, orphanRemoval: true)]
  28.     protected Collection $activities;
  29.     public function __toString()
  30.     {
  31.         return $this->titleCategory;
  32.     } 
  33.     public function __construct()
  34.     {
  35.         $this->calendars = new ArrayCollection();
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getTitleCategory(): ?string
  42.     {
  43.         return $this->titleCategory;
  44.     }
  45.     public function setTitleCategory(string $titleCategory): static
  46.     {
  47.         $this->titleCategory = $titleCategory;
  48.         return $this;
  49.     }
  50.     public function getImage(): ?string
  51.     {
  52.         return $this->image;
  53.     }
  54.     public function setImage(string $image): static
  55.     {
  56.         $this->image = $image;
  57.         return $this;
  58.     }     
  59.     public function isActivity(): ?bool
  60.     {
  61.         return $this->activity;
  62.     }
  63.     public function setActivity(bool $activity): static
  64.     {
  65.         $this->activity = $activity;
  66.         return $this;
  67.     }
  68.    /**
  69.      * @return Collection<int, Calendar>
  70.      */
  71.     public function getCalendars(): Collection
  72.     {
  73.         return $this->calendars;
  74.     }
  75.     public function getCategorySetting(): ?CategorySetting
  76.     {
  77.         return $this->categorySetting;
  78.     }
  79.     public function setCategorySetting(CategorySetting $categorySetting): static
  80.     {
  81.         // set the owning side of the relation if necessary
  82.         if ($categorySetting->getCategoriesTitle() !== $this) {
  83.             $categorySetting->setCategoriesTitle($this);
  84.         }
  85.         $this->categorySetting = $categorySetting;
  86.         return $this;
  87.     }
  88. }