<?phpnamespace App\Entity\Tutoring;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\Tutoring\SpaylineRepository;use App\Entity\Tutoring\Spayment;use App\Traits\Actions;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: SpaylineRepository::class)]#[ORM\Table(name: 'hs_tc_tutoring_spayline')]#[ApiResource]class Spayline{ use Actions; #[ORM\ManyToOne(targetEntity: Spayment::class, inversedBy: "items")] #[ORM\JoinColumn(nullable: false)] private Spayment $payment; #[ORM\ManyToOne(targetEntity: Owe::class, inversedBy: "items")] #[ORM\JoinColumn(nullable: true)] private Owe $owe; #[ORM\Column(name: "amount", type: "float")] private float $amount; public function __construct() { $this->createAt=new \DateTime('now'); $this->published=false; } /** * @return Spayment */ public function getPayment(): ?Spayment { return $this->payment; } /** * @param Spayment $payment */ public function setPayment(?Spayment $payment): Spayline { $this->payment = $payment; return $this; } /** * @return Owe */ public function getOwe(): ?Owe { return $this->owe; } /** * @param Owe $owe */ public function setOwe(?Owe $owe): Spayline { $this->owe = $owe; return $this; } /** * Set amount * * @param float $amount * * @return Spayline */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Get amount * * @return float */ public function getAmount() { return $this->amount; } public function getLabel() { if($this->getOwe()->getMonth()->getStartAt()>$this->getPayment()->getPublishedAt()){ return "<span class='label label-success' style='margin-left: 5px;'>".$this->getOwe()->getMonth()." (".$this->getAmount()." DH)"."</span>"; } elseif($this->getOwe()->getMonth()->getEndAt()<$this->getPayment()->getPublishedAt()){ return "<span class='label label-danger' style='margin-left: 5px;'>".$this->getOwe()->getMonth()." (".$this->getAmount()." DH)"."</span>"; } else{ return "<span class='label label-info' style='margin-left: 5px;'>".$this->getOwe()->getMonth()." (".$this->getAmount()." DH)"."</span>"; } }}