<?php
namespace App\Entity;
use App\Repository\MarkRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\SerializedName;
use App\Annotation\DashboardAnnotation as Dashboard;
use App\Annotation\FormBuildAnnotation as FormBuild;
/**
* @ORM\Entity(repositoryClass=MarkRepository::class)
* @Dashboard(generation=true, name="Марка авто")
* @ORM\Table(indexes={
* @ORM\Index(name="mark_title_idx", columns={"title"})
* })
*/
class Mark
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"collection", "selection/param"})
* @Dashboard(label="Номер", only=true)
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Groups({"collection", "selection/param"})
* @Dashboard(label="Название марки")
* @FormBuild(component="input")
*/
private $title;
/**
* @ORM\Column(type="boolean")
* @Serializer\Groups({"collection"})
* @FormBuild(component="switch")
* @Dashboard(label="Скрыть на сайте", only=true, inverse=true)
*/
private $public = true;
/**
* @ORM\OneToMany(targetEntity=Model::class, mappedBy="mark", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $models;
public function __construct()
{
$this->models = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function isPublic(): ?bool
{
return $this->public;
}
public function setPublic(bool $public): self
{
$this->public = $public;
return $this;
}
/**
* @return Collection<int, Model>
*/
public function getModels(): Collection
{
return $this->models;
}
public function addModel(Model $model): self
{
if (!$this->models->contains($model)) {
$this->models[] = $model;
$model->setMark($this);
}
return $this;
}
public function removeModel(Model $model): self
{
if ($this->models->removeElement($model)) {
// set the owning side to null (unless already changed)
if ($model->getMark() === $this) {
$model->setMark(null);
}
}
return $this;
}
}