src/Flexy/ShopBundle/Entity/Shipping/ShippingRule.php line 17
<?php
namespace App\Flexy\ShopBundle\Entity\Shipping;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Repository\Shipping\ShippingRuleRepository;
use App\Flexy\ShopBundle\Validator\UniqueShippingRule;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: ShippingRuleRepository::class)]
#[UniqueShippingRule(
shippingMethodProperty: "shippingMethod",
factorTypeProperty: "factorType",
message: "Shipping rule with these values already exists."
)]
class ShippingRule implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private string $name = "";
/**
*
* @example The minimum value depend on the typeCalculation and valueCalculation
*/
#[ORM\Column(type: 'float')]
private ?float $min = null;
/**
*
* @example The maximum value depend on the typeCalculation and valueCalculation
*/
#[ORM\Column(type: 'float')]
private ?float $max = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $priority = null;
#[ORM\ManyToOne(targetEntity: ShippingMethod::class, inversedBy: 'shippingRules')]
private ?\App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod $shippingMethod = null;
/**
*
* @example [amount|percent|amount-per-unit]
*/
#[ORM\Column(type: 'string', length: 255)]
private ?string $typeCalculation = null;
/**
*
* @example The related value to the type of calculation
*/
#[ORM\Column(type: 'float')]
private ?float $valueCalculation = null;
/**
*
* @example [price|distance|volume|weight|dimension] The factor calculated for this rule
*/
#[ORM\Column(length: 255, nullable: true)]
private ?string $factorType = "price";
/**
*
* @example [add|substract|replace] the method of calculation applied
*/
#[ORM\Column(length: 255, nullable: true)]
private ?string $adjustmentType = "replace";
public function __toString(): string
{
return $this->factorType. " -" .$this->typeCalculation." : ".$this->valueCalculation.", (Min ".$this->min.") (Max ".$this->max.")";
}
public function __construct()
{
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getMin(): ?float
{
return $this->min;
}
public function setMin(float $min): self
{
$this->min = $min;
return $this;
}
public function getMax(): ?float
{
return $this->max;
}
public function setMax(float $max): self
{
$this->max = $max;
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(int $priority): self
{
$this->priority = $priority;
return $this;
}
public function getShippingMethod(): ?ShippingMethod
{
return $this->shippingMethod;
}
public function setShippingMethod(?ShippingMethod $shippingMethod): self
{
$this->shippingMethod = $shippingMethod;
return $this;
}
public function getTypeCalculation(): ?string
{
return $this->typeCalculation;
}
public function setTypeCalculation(string $typeCalculation): self
{
$this->typeCalculation = $typeCalculation;
return $this;
}
public function getValueCalculation(): ?float
{
return $this->valueCalculation;
}
public function setValueCalculation(float $valueCalculation): self
{
$this->valueCalculation = $valueCalculation;
return $this;
}
public function getFactorType(): ?string
{
return $this->factorType;
}
public function setFactorType(?string $factorType): self
{
$this->factorType = $factorType;
return $this;
}
public function getAdjustmentType(): ?string
{
return $this->adjustmentType;
}
public function setAdjustmentType(?string $adjustmentType): self
{
$this->adjustmentType = $adjustmentType;
return $this;
}
}