src/Shop/Doctrine/Entity/Feature.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Shop\Doctrine\Entity;
  4. use Doctrine\ORM\Mapping\Column;
  5. use Doctrine\ORM\Mapping\Entity;
  6. use Doctrine\ORM\Mapping\GeneratedValue;
  7. use Doctrine\ORM\Mapping\Id;
  8. use Doctrine\ORM\Mapping\Table;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints\NotBlank;
  12. use Symfony\Component\Validator\Constraints\NotEqualTo;
  13. use Symfony\Component\Validator\Constraints\Regex;
  14. #[Entity]
  15. #[Table(name'`shop_feature`')]
  16. #[UniqueEntity('code')]
  17. class Feature
  18. {
  19.     #[Id]
  20.     #[Column(type'integer')]
  21.     #[GeneratedValue]
  22.     #[Groups(['product'])]
  23.     private ?int $id null;
  24.     #[Column(uniquetrue)]
  25.     #[NotBlank]
  26.     #[NotEqualTo(value'id')]
  27.     #[NotEqualTo(value'name')]
  28.     #[NotEqualTo(value'description')]
  29.     #[NotEqualTo(value'thumbnail')]
  30.     #[NotEqualTo(value'images')]
  31.     #[NotEqualTo(value'taxonomy')]
  32.     #[NotEqualTo(value'brand')]
  33.     #[Regex(pattern'/^[a-z-]+$/')]
  34.     #[Groups(['product'])]
  35.     private string $code;
  36.     #[Column]
  37.     #[NotBlank]
  38.     #[Groups(['product'])]
  39.     private string $name;
  40.     #[Column(type'feature_type')]
  41.     #[Groups(['product'])]
  42.     private FeatureType $featureType;
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getCode(): string
  48.     {
  49.         return $this->code;
  50.     }
  51.     public function setCode(string $code): void
  52.     {
  53.         $this->code $code;
  54.     }
  55.     public function getName(): string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): void
  60.     {
  61.         $this->name $name;
  62.     }
  63.     public function getFeatureType(): FeatureType
  64.     {
  65.         return $this->featureType;
  66.     }
  67.     public function setFeatureType(FeatureType $featureType): void
  68.     {
  69.         $this->featureType $featureType;
  70.     }
  71. }