src/Entity/Brand.php line 14

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