<?php
namespace App\Entity;
use App\Repository\ActionRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=ActionRepository::class)
* @ORM\Table(name="action", uniqueConstraints={@ORM\UniqueConstraint(columns={"code"})})
* @UniqueEntity(fields={"code"}, message="Le code de l'action doit ĂȘtre unique")
*/
class Action
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* Code logique: CREATE, READ, UPDATE, DELETE, ACTIVER
* @ORM\Column(type="string", length=50, unique=true)
* @Assert\NotBlank(message="Le code de l'action est obligatoire")
*/
private ?string $code = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $description = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function __toString(): string
{
return $this->code ?? 'action';
}
}