src/Entity/ModuleFamily.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ModuleFamilyRepository;
  4. use App\Entity\Traits\BaseDataTrait;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Mapping\UniqueConstraint;
  7. use EightMarq\CoreComponent\Entity\BaseEntity;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Table(name="module_families", uniqueConstraints={
  13.  *     @UniqueConstraint(columns={"name", "code", "deleted_at"})
  14.  * })
  15.  *
  16.  * @UniqueEntity(fields={"name", "code"}, errorPath="name", message="error.entity.not_unique"))
  17.  *
  18.  * @ORM\Entity(repositoryClass=ModuleFamilyRepository::class)
  19.  *
  20.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true, hardDelete=false)
  21.  *
  22.  */
  23. class ModuleFamily extends BaseEntity
  24. {
  25.     use BaseDataTrait;
  26.     /**
  27.      * @var string | null
  28.      *
  29.      * @ORM\Column(type="string", nullable=true)
  30.      *
  31.      * @Assert\NotBlank()
  32.      */
  33.     protected $name;
  34.     /**
  35.      * @var string | null
  36.      *
  37.      * @ORM\Column(type="string", nullable=true)
  38.      *
  39.      */
  40.     protected $code;
  41.     /**
  42.      * @return string|null
  43.      */
  44.     public function __toString(): string
  45.     {
  46.         $code $this->getCode() ? ' - '.$this->getCode() : '';
  47.         return $this->getName().$code;
  48.     }
  49. }