src/Flexy/ShopBundle/Entity/Shipping/ShippingRule.php line 17

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Repository\Shipping\ShippingRuleRepository;
  5. use App\Flexy\ShopBundle\Validator\UniqueShippingRule;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ApiResource]
  8. #[ORM\Entity(repositoryClass: ShippingRuleRepository::class)]
  9. #[UniqueShippingRule(
  10.     shippingMethodProperty: "shippingMethod",
  11.     factorTypeProperty: "factorType",
  12.     message: "Shipping rule with these values already exists."
  13. )]
  14. class ShippingRule implements \Stringable
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type: 'integer')]
  19.     private $id;
  20.     #[ORM\Column(type: 'string', length: 255)]
  21.     private string $name = "";
  22.     #[ORM\Column(type: 'float')]
  23.     private ?float $min = null;
  24.     #[ORM\Column(type: 'float')]
  25.     private ?float $max = null;
  26.     #[ORM\Column(type: 'integer', nullable: true)]
  27.     private ?int $priority = null;
  28.     #[ORM\ManyToOne(targetEntity: ShippingMethod::class, inversedBy: 'shippingRules')]
  29.     private ?\App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod $shippingMethod = null;
  30.     #[ORM\Column(type: 'string', length: 255)]
  31.     private ?string $typeCalculation = null;
  32.     #[ORM\Column(type: 'float')]
  33.     private ?float $valueCalculation = null;
  34.     #[ORM\Column(length: 255, nullable: true)]
  35.     private ?string $factorType = null;
  36.     #[ORM\Column(length: 255, nullable: true)]
  37.     private ?string $adjustmentType = null;
  38.     public function __toString(): string
  39.     {
  40.         return $this->factorType. " -" .$this->typeCalculation." : ".$this->valueCalculation.", (Min ".$this->min.") (Max ".$this->max.")";
  41.     }
  42.     public function __construct()
  43.     {
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): self
  54.     {
  55.         $this->name = $name;
  56.         return $this;
  57.     }
  58.     public function getMin(): ?float
  59.     {
  60.         return $this->min;
  61.     }
  62.     public function setMin(float $min): self
  63.     {
  64.         $this->min = $min;
  65.         return $this;
  66.     }
  67.     public function getMax(): ?float
  68.     {
  69.         return $this->max;
  70.     }
  71.     public function setMax(float $max): self
  72.     {
  73.         $this->max = $max;
  74.         return $this;
  75.     }
  76.     public function getPriority(): ?int
  77.     {
  78.         return $this->priority;
  79.     }
  80.     public function setPriority(int $priority): self
  81.     {
  82.         $this->priority = $priority;
  83.         return $this;
  84.     }
  85.     public function getShippingMethod(): ?ShippingMethod
  86.     {
  87.         return $this->shippingMethod;
  88.     }
  89.     public function setShippingMethod(?ShippingMethod $shippingMethod): self
  90.     {
  91.         $this->shippingMethod = $shippingMethod;
  92.         return $this;
  93.     }
  94.     public function getTypeCalculation(): ?string
  95.     {
  96.         return $this->typeCalculation;
  97.     }
  98.     public function setTypeCalculation(string $typeCalculation): self
  99.     {
  100.         $this->typeCalculation = $typeCalculation;
  101.         return $this;
  102.     }
  103.     public function getValueCalculation(): ?float
  104.     {
  105.         return $this->valueCalculation;
  106.     }
  107.     public function setValueCalculation(float $valueCalculation): self
  108.     {
  109.         $this->valueCalculation = $valueCalculation;
  110.         return $this;
  111.     }
  112.     public function getFactorType(): ?string
  113.     {
  114.         return $this->factorType;
  115.     }
  116.     public function setFactorType(?string $factorType): self
  117.     {
  118.         $this->factorType = $factorType;
  119.         return $this;
  120.     }
  121.     public function getAdjustmentType(): ?string
  122.     {
  123.         return $this->adjustmentType;
  124.     }
  125.     public function setAdjustmentType(?string $adjustmentType): self
  126.     {
  127.         $this->adjustmentType = $adjustmentType;
  128.         return $this;
  129.     }
  130. }