<?php

namespace AutoAdmin\Bundle\Content\Entity\Traits;

use AutoAdmin\Bundle\Content\Validator as AutoAdminAssert;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * Beware: indexed-column max varchar length in utf8_general_ci is 255, or 191 in utf8mb4_general_ci (MySQL limitation)
 */
trait SlugTrait
{
    #[ORM\Column(name: 'slug', type: Types::STRING, length: 255)]
    #[AutoAdminAssert\UniqueSlug]
    #[Groups(['slug'])]
    protected string $slug = '';

    public function getSlug(): ?string
    {
        return $this->slug;
    }

    public function setSlug(string $slug): void
    {
        $this->slug = $slug;
    }
}
