src/Entity/Manufacturer.php line 24

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