<?php
namespace App\Entity;
use App\Repository\PageRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=PageRepository::class)
* @ORM\Table(name="page", uniqueConstraints={@ORM\UniqueConstraint(columns={"code"})})
* @UniqueEntity(fields={"code"}, message="Le code de la page doit ĂȘtre unique")
*/
class Page
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=100, unique=true)
* @Assert\NotBlank
*/
private ?string $code = null;
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function __toString(): string
{
return $this->code ?? 'page';
}
}