<?php
namespace App\Entity;
use App\Entity\Enum\TransactionStatus;
use App\Repository\BenefactorTransactionCheckRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: BenefactorTransactionCheckRepository::class)]
class BenefactorTransactionCheck extends BenefactorTransaction
{
#[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'benefactorTransactionChecks')]
private ?Check $check = null;
public function __construct()
{
$this->setStatus(TransactionStatus::Waiting);
}
public function getCheck(): ?Check
{
return $this->check;
}
public function setCheck(?Check $check): self
{
$this->check = $check;
return $this;
}
public function cancel(): void
{
if ($check = $this->getCheck()) {
foreach ($check->getBenefactorTransactionChecks() as $transactionCheck) {
$transactionCheck->setStatus(TransactionStatus::Cancelled);
}
$check->setIsCancelled(true);
}
}
}