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 Gedmo\Mapping\Annotation as Gedmo;
  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\Column(type="float")
  25.      */
  26.     private $percentage;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $icon;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity=Bike::class, mappedBy="category")
  33.      */
  34.     private $bikes;
  35.     /**
  36.      * @ORM\Column(type="datetime_immutable")
  37.      * @Gedmo\Timestampable(on="create")
  38.      */
  39.     private $created_at;
  40.     /**
  41.      * @ORM\Column(type="datetime_immutable")
  42.      * @Gedmo\Timestampable(on="update")
  43.      */
  44.     private $updated_at;
  45.     public function __construct()
  46.     {
  47.         $this->bikes = new ArrayCollection();
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getTitle(): ?string
  54.     {
  55.         return $this->title;
  56.     }
  57.     public function setTitle(string $title): self
  58.     {
  59.         $this->title $title;
  60.         return $this;
  61.     }
  62.     public function getPercentage(): ?float
  63.     {
  64.         return $this->percentage;
  65.     }
  66.     public function setPercentage(float $percentage): self
  67.     {
  68.         $this->percentage $percentage;
  69.         return $this;
  70.     }
  71.     public function getIcon(): ?string
  72.     {
  73.         return $this->icon;
  74.     }
  75.     public function setIcon(string $icon): self
  76.     {
  77.         $this->icon $icon;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, Bike>
  82.      */
  83.     public function getBikes(): Collection
  84.     {
  85.         return $this->bikes;
  86.     }
  87.     public function addBike(Bike $bike): self
  88.     {
  89.         if (!$this->bikes->contains($bike)) {
  90.             $this->bikes[] = $bike;
  91.             $bike->setCategory($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeBike(Bike $bike): self
  96.     {
  97.         if ($this->bikes->removeElement($bike)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($bike->getCategory() === $this) {
  100.                 $bike->setCategory(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     public function getCreatedAt(): ?\DateTimeImmutable
  106.     {
  107.         return $this->created_at;
  108.     }
  109.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  110.     {
  111.         $this->created_at $created_at;
  112.         return $this;
  113.     }
  114.     public function getUpdatedAt(): ?\DateTimeImmutable
  115.     {
  116.         return $this->updated_at;
  117.     }
  118.     public function setUpdatedAt(\DateTimeImmutable $updated_at): self
  119.     {
  120.         $this->updated_at $updated_at;
  121.         return $this;
  122.     }
  123. }