src/Entity/Shop.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\MainTranslationTrait;
  4. use App\Entity\Translation\ShopTranslation;
  5. use App\Repository\ShopRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Gedmo\Translatable\Translatable;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use JsonSerializable;
  11. #[ORM\Table(name'shop')]
  12. #[ORM\Entity(repositoryClassShopRepository::class)]
  13. #[Gedmo\TranslationEntity(class: ShopTranslation::class)]
  14. class Shop implements Translatable,JsonSerializable
  15. {
  16.     use MainTranslationTrait;
  17.     const TRANSLATION_ENTITY ShopTranslation::class;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     #[ORM\Column(type'string'nullabletrue)]
  23.     #[Gedmo\Translatable]
  24.     #[Groups("shop:read")]
  25.     private ?string $title null;
  26.     #[ORM\Column(type'float'nullabletrue)]
  27.     #[Groups("shop:read")]
  28.     private ?float $price null;
  29.     #[ORM\Column(type'float'nullabletrue)]
  30.     #[Groups("shop:read")]
  31.     private ?float $discountedPrice null;
  32.     #[Groups("shop:read")]
  33.     #[ORM\Column(type'string'nullabletrue)]
  34.     private ?string $image null;
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function __toString(): string
  40.     {
  41.         return $this->title ?? "";
  42.     }
  43.     public function getTitle(): ?string
  44.     {
  45.         return $this->title;
  46.     }
  47.     public function setTitle(?string $title): static
  48.     {
  49.         $this->title $title;
  50.         return $this;
  51.     }
  52.     public function getPrice(): ?float
  53.     {
  54.         return $this->price;
  55.     }
  56.     public function setPrice(?float $price): static
  57.     {
  58.         $this->price $price;
  59.         return $this;
  60.     }
  61.     public function getDiscountedPrice(): ?float
  62.     {
  63.         return $this->discountedPrice;
  64.     }
  65.     public function setDiscountedPrice(?float $discountedPrice): static
  66.     {
  67.         $this->discountedPrice $discountedPrice;
  68.         return $this;
  69.     }
  70.     public function getImage(): ?string
  71.     {
  72.         return $this->image;
  73.     }
  74.     public function setImage(?string $image): static
  75.     {
  76.         $this->image $image;
  77.         return $this;
  78.     }
  79.     public function jsonSerialize(): array
  80.     {
  81.         return [
  82.             'id' => $this->id,
  83.             'title' => $this->title,
  84.             'price' => $this->price,
  85.             'discountedPrice' => $this->discountedPrice,
  86.             'image' => $this->image,
  87.         ];
  88.     }
  89. }