src/Entity/Tutoring/Spayline.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Tutoring;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Tutoring\SpaylineRepository;
  5. use App\Entity\Tutoring\Spayment;
  6. use App\Traits\Actions;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSpaylineRepository::class)]
  9. #[ORM\Table(name'hs_tc_tutoring_spayline')]
  10. #[ApiResource]
  11. class Spayline
  12. {
  13.     use Actions;
  14.     #[ORM\ManyToOne(targetEntitySpayment::class, inversedBy"items")]
  15.     #[ORM\JoinColumn(nullablefalse)]
  16.     private Spayment $payment;
  17.     #[ORM\ManyToOne(targetEntityOwe::class, inversedBy"items")]
  18.     #[ORM\JoinColumn(nullabletrue)]
  19.     private Owe $owe;
  20.     #[ORM\Column(name"amount"type"float")]
  21.     private float $amount;
  22.     public function __construct()
  23.     {
  24.         
  25.         $this->createAt=new \DateTime('now');
  26.         $this->published=false;
  27.     }
  28.     /**
  29.      * @return Spayment
  30.      */
  31.     public function getPayment(): ?Spayment
  32.     {
  33.         return $this->payment;
  34.     }
  35.     /**
  36.      * @param Spayment $payment
  37.      */
  38.     public function setPayment(?Spayment $payment): Spayline
  39.     {
  40.         $this->payment $payment;
  41.         return $this;
  42.     }
  43.     /**
  44.      * @return Owe
  45.      */
  46.     public function getOwe(): ?Owe
  47.     {
  48.         return $this->owe;
  49.     }
  50.     /**
  51.      * @param Owe $owe
  52.      */
  53.     public function setOwe(?Owe $owe): Spayline
  54.     {
  55.         $this->owe $owe;
  56.         return $this;
  57.     }
  58.     /**
  59.      * Set amount
  60.      *
  61.      * @param float $amount
  62.      *
  63.      * @return Spayline
  64.      */
  65.     public function setAmount($amount)
  66.     {
  67.         $this->amount $amount;
  68.         return $this;
  69.     }
  70.     /**
  71.      * Get amount
  72.      *
  73.      * @return float
  74.      */
  75.     public function getAmount()
  76.     {
  77.         return $this->amount;
  78.     }
  79.     public function getLabel()
  80.     {
  81.         if($this->getOwe()->getMonth()->getStartAt()>$this->getPayment()->getPublishedAt()){
  82.             return "<span class='label label-success' style='margin-left: 5px;'>".$this->getOwe()->getMonth()." (".$this->getAmount()." DH)"."</span>";
  83.         }
  84.         elseif($this->getOwe()->getMonth()->getEndAt()<$this->getPayment()->getPublishedAt()){
  85.             return "<span class='label label-danger' style='margin-left: 5px;'>".$this->getOwe()->getMonth()." (".$this->getAmount()." DH)"."</span>";
  86.         }
  87.         else{
  88.             return "<span class='label label-info' style='margin-left: 5px;'>".$this->getOwe()->getMonth()." (".$this->getAmount()." DH)"."</span>";
  89.         }
  90.     }
  91. }