src/Entity/Management/Subscription/Discount.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Management\Subscription;
  3. use App\Model\TimestampableTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use App\Entity\Management\Subscription\Offer;
  9. /**
  10.  * Discount
  11.  *
  12.  * @ORM\Table(name="Discount")
  13.  * @ORM\Entity(repositoryClass="App\Repository\Management\DiscountRepository")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class Discount
  17. {
  18.     use TimestampableTrait;
  19.     /**
  20.      * @var integer
  21.      *
  22.      * @ORM\Column(name="id", type="integer")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @var string
  29.      *
  30.      * @ORM\Column(name="title", type="string", length=255,unique=true)
  31.      *
  32.      */
  33.     private $title;
  34.     /**
  35.      * @var string
  36.      *
  37.      * @ORM\Column(type="string", length=255,unique=true)
  38.      *
  39.      */
  40.     private $codePromo;
  41.     /**
  42.      * @var integer
  43.      *
  44.      * @ORM\Column(name="percent", type="decimal", scale=2 ,nullable=true)
  45.      */
  46.     private $percent;
  47.     /**
  48.      * @var string
  49.      * @ORM\Column(name="duration",type="string",nullable=true)
  50.      */
  51.     private $duration;
  52.     /**
  53.      * @ORM\Column(name="description",type="text",nullable=true)
  54.      */
  55.     private $description;
  56.     /**
  57.      * @ORM\Column(name="amount",type="integer",nullable=true)
  58.      */
  59.     private $amount;
  60.     /**
  61.      * @ORM\Column(name="stripe_id",type="string",length=255,nullable=true)
  62.      *
  63.      */
  64.     private $stripeId;
  65.     /**
  66.      * @var string
  67.      * @ORM\Column(name="duration_in_months",type="integer",nullable=true)
  68.      */
  69.     private $durationInMonths;
  70.     /**
  71.      * @var \DateTime
  72.      * @ORM\Column(name="start_valid",type="datetime", nullable=true)
  73.      */
  74.     private $startValid;
  75.     /**
  76.      * @var \DateTime
  77.      * @ORM\Column(name="end_valid",type="datetime", nullable=true)
  78.      */
  79.     private $endValid;
  80.     /**
  81.      * @ORM\Column(name="online",type="boolean",nullable=true)
  82.      */
  83.     private $online;
  84.     /**
  85.      * @ORM\Column(type="boolean",nullable=true)
  86.      */
  87.     private $isDelete;
  88.     /**
  89.      * @ORM\ManyToMany(targetEntity=Offer::class)
  90.      */
  91.     private $allowOffer;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity=Discount::class)
  94.      */
  95.     private $moreChildReduce;
  96.     /*****************   fin    **********************/
  97.     public function __construct()
  98.     {
  99.         $this->allowOffer = new ArrayCollection();
  100.     }
  101.     /**
  102.      * Get id
  103.      *
  104.      * @return integer
  105.      */
  106.     public function getId()
  107.     {
  108.         return $this->id;
  109.     }
  110.     /**
  111.      * Set title
  112.      *
  113.      * @param string $title
  114.      * @return Discount
  115.      */
  116.     public function setTitle($title)
  117.     {
  118.         $this->title = $title;
  119.         return $this;
  120.     }
  121.     /**
  122.      * Get title
  123.      *
  124.      * @return string
  125.      */
  126.     public function getTitle()
  127.     {
  128.         return $this->title;
  129.     }
  130.     /**
  131.      * Set percent
  132.      *
  133.      * @param integer $percent
  134.      * @return Discount
  135.      */
  136.     public function setPercent($percent)
  137.     {
  138.         $this->percent = $percent;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Get percent
  143.      *
  144.      * @return integer
  145.      */
  146.     public function getPercent()
  147.     {
  148.         return $this->percent;
  149.     }
  150.     /**
  151.      * @return string
  152.      */
  153.     public function getDuration()
  154.     {
  155.         return $this->duration;
  156.     }
  157.     /**
  158.      * @param string $duration
  159.      */
  160.     public function setDuration($duration)
  161.     {
  162.         $this->duration = $duration;
  163.     }
  164.     /**
  165.      * @return mixed
  166.      */
  167.     public function getOffers()
  168.     {
  169.         return $this->offers;
  170.     }
  171.     /**
  172.      * @param mixed $offers
  173.      */
  174.     public function addOffers($offers)
  175.     {
  176.         $this->offers[] = $offers;
  177.     }
  178.     /**
  179.      * @param mixed $offers
  180.      */
  181.     public function setOffers($offers)
  182.     {
  183.         $this->offers = $offers;
  184.     }
  185.     public function __toString()
  186.     {
  187.         return $this->title;
  188.     }
  189.     /**
  190.      * @return string
  191.      */
  192.     public function getDurationInMonths()
  193.     {
  194.         return $this->durationInMonths;
  195.     }
  196.     /**
  197.      * @param string $durationInMonths
  198.      */
  199.     public function setDurationInMonths($durationInMonths)
  200.     {
  201.         $this->durationInMonths = $durationInMonths;
  202.     }
  203.     /**
  204.      * @return mixed
  205.      */
  206.     public function getDescription()
  207.     {
  208.         return $this->description;
  209.     }
  210.     /**
  211.      * @param mixed $description
  212.      */
  213.     public function setDescription($description)
  214.     {
  215.         $this->description = $description;
  216.     }
  217.     /**
  218.      * @return mixed
  219.      */
  220.     public function getAmount()
  221.     {
  222.         return $this->amount;
  223.     }
  224.     /**
  225.      * @param mixed $amount
  226.      */
  227.     public function setAmount($amount)
  228.     {
  229.         $this->amount = $amount;
  230.     }
  231.     /**
  232.      * @return mixed
  233.      */
  234.     public function getStripeId()
  235.     {
  236.         return $this->stripeId;
  237.     }
  238.     /**
  239.      * @param mixed $stripeId
  240.      */
  241.     public function setStripeId($stripeId)
  242.     {
  243.         $this->stripeId = $stripeId;
  244.     }
  245.     /**
  246.      * @return date
  247.      */
  248.     public function getStartValid()
  249.     {
  250.         return $this->startValid;
  251.     }
  252.     /**
  253.      * @param date $startValid
  254.      */
  255.     public function setStartValid($startValid)
  256.     {
  257.         $this->startValid = $startValid;
  258.     }
  259.     /**
  260.      * @return date
  261.      */
  262.     public function getEndValid()
  263.     {
  264.         return $this->endValid;
  265.     }
  266.     /**
  267.      * @param date $endValid
  268.      */
  269.     public function setEndValid($endValid)
  270.     {
  271.         $this->endValid = $endValid;
  272.     }
  273.     /**
  274.      * @return mixed
  275.      */
  276.     public function getDiscountHistory()
  277.     {
  278.         return $this->discountHistory;
  279.     }
  280.     /**
  281.      * @param mixed $discountHistory
  282.      */
  283.     public function setDiscountHistory($discountHistory)
  284.     {
  285.         $this->discountHistory = $discountHistory;
  286.     }
  287.     /**
  288.      * @return array
  289.      */
  290.     public function getChoiceOffer()
  291.     {
  292.         return $this->choiceOffer;
  293.     }
  294.     /**
  295.      * @param array $choiceOffer
  296.      */
  297.     public function setChoiceOffer( $choiceOffer)
  298.     {
  299.         $this->choiceOffer = $choiceOffer;
  300.     }
  301.     /**
  302.      * @return string
  303.      */
  304.     public function getCodePromo(): ?string
  305.     {
  306.         return $this->codePromo;
  307.     }
  308.     /**
  309.      * @param string $codePromo
  310.      */
  311.     public function setCodePromo(string $codePromo): void
  312.     {
  313.         $this->codePromo = $codePromo;
  314.     }
  315.     /**
  316.      * @return mixed
  317.      */
  318.     public function getOnline()
  319.     {
  320.         return $this->online;
  321.     }
  322.     /**
  323.      * @param mixed $online
  324.      */
  325.     public function setOnline($online): void
  326.     {
  327.         $this->online = $online;
  328.     }
  329.     /**
  330.      * @return mixed
  331.      */
  332.     public function getIsDelete()
  333.     {
  334.         return $this->isDelete;
  335.     }
  336.     /**
  337.      * @param mixed $isDelete
  338.      */
  339.     public function setIsDelete($isDelete): void
  340.     {
  341.         $this->isDelete = $isDelete;
  342.     }
  343.     public function actif(){
  344.         if($this->online){
  345.             if(!is_null($this->startValid)){
  346.                 $now = new \DateTime();
  347.                 return $this->startValid<=$now && $now<=$this->endValid;
  348.             }
  349.             return true;
  350.         }
  351.         return false;
  352.     }
  353.     public function setAllowOffer(ArrayCollection $packs): void
  354.     {
  355.         $this->allowOffer = $packs;
  356.     }
  357.     public function addAllowOffer(Offer $offer): void
  358.     {
  359.         if(!$this->allowOffer->contains($offer))
  360.             $this->allowOffer[] = $offer;
  361.     }
  362.     public function getAllowOffer(){
  363.         return $this->allowOffer;
  364.     }
  365.     /**
  366.      * @return mixed
  367.      */
  368.     public function getMoreChildReduce()
  369.     {
  370.         return $this->moreChildReduce;
  371.     }
  372.     /**
  373.      * @param mixed $moreChildReduce
  374.      */
  375.     public function setMoreChildReduce($moreChildReduce): void
  376.     {
  377.         $this->moreChildReduce = $moreChildReduce;
  378.     }
  379. }