src/Entity/Page.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PageRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass=PageRepository::class)
  9.  * @ORM\Table(name="page", uniqueConstraints={@ORM\UniqueConstraint(columns={"code"})})
  10.  * @UniqueEntity(fields={"code"}, message="Le code de la page doit ĂȘtre unique")
  11.  */
  12. class Page
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private ?int $id null;
  20.     /**
  21.      * @ORM\Column(type="string", length=100, unique=true)
  22.      * @Assert\NotBlank
  23.      */
  24.     private ?string $code null;
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getCode(): ?string
  30.     {
  31.         return $this->code;
  32.     }
  33.     public function setCode(string $code): self
  34.     {
  35.         $this->code $code;
  36.         return $this;
  37.     }
  38.     public function __toString(): string
  39.     {
  40.         return $this->code ?? 'page';
  41.     }
  42. }