src/Entity/Category.php line 14

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. use App\Entity\Service;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CategoryRepository::class)
  10.  */
  11. class Category
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @ORM\OneToMany(targetEntity=Service::class, mappedBy="category")
  25.      */
  26.     private $services;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="category")
  29.      */
  30.     private $users;
  31.     /**
  32.      * @ORM\Column(type="text")
  33.      */
  34.     private $content;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $picture;
  39.     /**
  40.      * @ORM\Column(type="datetime",nullable=true)
  41.      */
  42.     private $created_At;
  43.     /**
  44.      * @ORM\Column(type="datetime",nullable=true)
  45.      */
  46.     private $updated_At;
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      */
  50.     private $deleted_At;
  51.     public function __construct()
  52.     {
  53.         $this->services = new ArrayCollection();
  54.         $this->users = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getTitle(): ?string
  61.     {
  62.         return $this->title;
  63.     }
  64.     public function setTitle(string $title): self
  65.     {
  66.         $this->title $title;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection<int, Service>
  71.      */
  72.     public function getServices(): Collection
  73.     {
  74.         return $this->services;
  75.     }
  76.     public function addService(Service $service): self
  77.     {
  78.         if (!$this->services->contains($service)) {
  79.             $this->services[] = $service;
  80.             $service->setCategory($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeService(Service $service): self
  85.     {
  86.         if ($this->services->removeElement($service)) {
  87.             // set the owning side to null (unless already changed)
  88.             if ($service->getCategory() === $this) {
  89.                 $service->setCategory(null);
  90.             }
  91.         }
  92.         return $this;
  93.     }
  94.     public function __toString()
  95.     {
  96.         return $this->title;
  97.     }
  98.     /**
  99.      * @return Collection<int, User>
  100.      */
  101.     public function getUsers(): Collection
  102.     {
  103.         return $this->users;
  104.     }
  105.     public function addUser(User $user): self
  106.     {
  107.         if (!$this->users->contains($user)) {
  108.             $this->users[] = $user;
  109.             $user->setCategory($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeUser(User $user): self
  114.     {
  115.         if ($this->users->removeElement($user)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($user->getCategory() === $this) {
  118.                 $user->setCategory(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getContent(): ?string
  124.     {
  125.         return $this->content;
  126.     }
  127.     public function setContent(string $content): self
  128.     {
  129.         $this->content $content;
  130.         return $this;
  131.     }
  132.     public function getPicture(): ?string
  133.     {
  134.         return $this->picture;
  135.     }
  136.     public function setPicture(string $picture): self
  137.     {
  138.         $this->picture $picture;
  139.         return $this;
  140.     }
  141.     public function getCreatedAt(): ?\DateTimeInterface
  142.     {
  143.         return $this->created_At;
  144.     }
  145.     public function setCreatedAt(\DateTimeInterface $created_At): self
  146.     {
  147.         $this->created_At $created_At;
  148.         return $this;
  149.     }
  150.     public function getUpdatedAt(): ?\DateTimeInterface
  151.     {
  152.         return $this->updated_At;
  153.     }
  154.     public function setUpdatedAt(\DateTimeInterface $updated_At): self
  155.     {
  156.         $this->updated_At $updated_At;
  157.         return $this;
  158.     }
  159.     public function getDeletedAt(): ?\DateTimeInterface
  160.     {
  161.         return $this->deleted_At;
  162.     }
  163.     public function setDeletedAt(?\DateTimeInterface $deleted_At): self
  164.     {
  165.         $this->deleted_At $deleted_At;
  166.         return $this;
  167.     }
  168. }