src/Entity/Model.php line 13
<?phpnamespace App\Entity;use App\Repository\ModelRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;#[ORM\Entity(repositoryClass: ModelRepository::class)]#[UniqueEntity(fields: ['model_name'], message: 'Il existe déjà un modèle avec ce nom.')]class Model{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255, unique: true)]private ?string $model_name = null;#[ORM\OneToMany(mappedBy: 'product_model', targetEntity: Product::class)]private Collection $products;#[ORM\ManyToOne(inversedBy: 'models')]#[ORM\JoinColumn(nullable: false)]private ?Brand $model_brand = null;public function __construct(){$this->products = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getModelName(): ?string{return $this->model_name;}public function setModelName(string $model_name): self{$this->model_name = $model_name;return $this;}/*** @return Collection<int, Product>*/public function getProducts(): Collection{return $this->products;}public function addProduct(Product $product): self{if (!$this->products->contains($product)) {$this->products->add($product);$product->setProductModel($this);}return $this;}public function removeProduct(Product $product): self{if ($this->products->removeElement($product)) {// set the owning side to null (unless already changed)if ($product->getProductModel() === $this) {$product->setProductModel(null);}}return $this;}public function getModelBrand(): ?Brand{return $this->model_brand;}public function setModelBrand(?Brand $model_brand): self{$this->model_brand = $model_brand;return $this;}public function __toString(): string{return $this->model_name;}}