src/Entity/Product/CreditPack.php line 34

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Entity\Product;
  12. use App\Entity\IdentifiableTrait;
  13. use App\Repository\Product\CreditPackRepository;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Gedmo\Timestampable\Traits\TimestampableEntity;
  16. use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
  17. use Sylius\Component\Resource\Model\ResourceInterface;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. #[ORM\Entity(repositoryClassCreditPackRepository::class)]
  20. #[ORM\Table(name'app_credit_pack')]
  21. #[SyliusCrudRoutes(alias'app.credit_pack'path'/admin/credit-packs'section'backend'templates'backend/crud'grid'app_backend_credit_pack'except: ['show'], vars: [
  22.     'all' => [
  23.         'subheader' => 'app.ui.manage_your_credit_packs',
  24.     ],
  25.     'index' => [
  26.         'icon' => 'euro sign',
  27.     ],
  28. ])]
  29. class CreditPack implements ResourceInterface
  30. {
  31.     use IdentifiableTrait;
  32.     use TimestampableEntity;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     #[Assert\Length(min2max55)]
  35.     private ?string $name null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     #[Assert\Length(min2max55)]
  38.     private ?string $shortDescription null;
  39.     #[ORM\Column(length10000nullabletrue)]
  40.     #[Assert\NotBlankAssert\Length(min2max1000)]
  41.     private ?string $description null;
  42.     #[ORM\Column]
  43.     #[Assert\NotBlankAssert\PositiveOrZero]
  44.     private ?int $price 0;
  45.     #[ORM\Column]
  46.     #[Assert\NotBlankAssert\PositiveOrZero]
  47.     private ?int $credits 0;
  48.     #[ORM\Column(type'boolean')]
  49.     private bool $enabled true;
  50.     private ?int $priceWithPromotion null;
  51.     private ?int $creditsWithPromotion null;
  52.     public function getName(): ?string
  53.     {
  54.         return $this->name;
  55.     }
  56.     public function setName(string $name): self
  57.     {
  58.         $this->name $name;
  59.         return $this;
  60.     }
  61.     public function getShortDescription(): ?string
  62.     {
  63.         return $this->shortDescription;
  64.     }
  65.     public function setShortDescription(?string $shortDescription): self
  66.     {
  67.         $this->shortDescription $shortDescription;
  68.         return $this;
  69.     }
  70.     public function getDescription(): ?string
  71.     {
  72.         return $this->description;
  73.     }
  74.     public function setDescription(?string $description): self
  75.     {
  76.         $this->description $description;
  77.         return $this;
  78.     }
  79.     public function getPrice(): ?int
  80.     {
  81.         return $this->price;
  82.     }
  83.     public function setPrice(int $price): self
  84.     {
  85.         $this->price $price;
  86.         return $this;
  87.     }
  88.     public function getCredits(): ?int
  89.     {
  90.         return $this->credits;
  91.     }
  92.     public function setCredits(int $credits): self
  93.     {
  94.         $this->credits $credits;
  95.         return $this;
  96.     }
  97.     public function getEnabled(): bool
  98.     {
  99.         return $this->enabled;
  100.     }
  101.     public function setEnabled(bool $enabled): self
  102.     {
  103.         $this->enabled $enabled;
  104.         return $this;
  105.     }
  106.     public function getPriceWithPromotion(): ?int
  107.     {
  108.         if (null === $this->priceWithPromotion) {
  109.             return $this->price;
  110.         }
  111.         return $this->priceWithPromotion;
  112.     }
  113.     public function setPriceWithPromotion(int $priceWithPromotion): self
  114.     {
  115.         $this->priceWithPromotion $priceWithPromotion;
  116.         return $this;
  117.     }
  118.     public function getCreditsWithPromotion(): ?int
  119.     {
  120.         if (null === $this->creditsWithPromotion) {
  121.             return $this->credits;
  122.         }
  123.         return $this->creditsWithPromotion;
  124.     }
  125.     public function setCreditsWithPromotion(int $creditsWithPromotion): self
  126.     {
  127.         $this->creditsWithPromotion $creditsWithPromotion;
  128.         return $this;
  129.     }
  130. }