<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: \App\Repository\PaletteCouleurRepository::class)]
class PaletteCouleur implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $designation= null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $code_hexa= null;
#[ORM\OneToMany(targetEntity: \App\Entity\Post::class, mappedBy: 'palettecouleur')]
private mixed $posts;
public function __construct()
{
$this->posts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDesignation(): ?string
{
return $this->designation;
}
public function setDesignation(?string $designation): self
{
$this->designation = $designation;
return $this;
}
public function getCodeHexa(): ?string
{
return $this->code_hexa;
}
public function setCodeHexa(?string $code_hexa): self
{
$this->code_hexa = $code_hexa;
return $this;
}
/**
* @return Collection|Post[]
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->setPalettecouleur($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
// set the owning side to null (unless already changed)
if ($post->getPalettecouleur() === $this) {
$post->setPalettecouleur(null);
}
}
return $this;
}
public function __toString(): string
{
return (string) $this->designation;
}
}