<?phpnamespace App\Entity\Formation;use ApiPlatform\Core\Annotation\ApiResource;use App\Entity\Schoolyear;use App\Entity\User;use App\Repository\Formation\AregulationRepository;use App\Traits\Actions;use Doctrine\ORM\Mapping as ORM;/** * Aregulation */#[ORM\Entity(repositoryClass: AregulationRepository::class)]#[ORM\Table(name: 'hs_tc_formation_aregulation')]#[ApiResource]class Aregulation implements \Stringable{ use Actions; #[ORM\ManyToOne(targetEntity: Intervenant::class, inversedBy: 'regulations')] #[ORM\JoinColumn(nullable: false)] private ?Intervenant $intervenant = null; #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(nullable: true)] private ?User $initie = null; /** * @var string */ #[ORM\Column(name: 'way', type: 'string', length: 255)] private $way; /** * @var float */ #[ORM\Column(name: 'amount', type: 'float')] private $amount; #[ORM\Column(name: 'doc_number', type: 'string', length: 255)] private string $docNumber = '11'; #[ORM\Column(name: 'cached', type: 'boolean')] private bool $cached = false; #[ORM\ManyToOne(targetEntity: Schoolyear::class)] #[ORM\JoinColumn(nullable: true)] private ?Schoolyear $schoolyear = null; /** * Aregulation constructor. */ public function __construct() { // date_default_timezone_set('Africa/Casablanca'); $this->publishedAt=new \DateTime('now'); $this->createAt=new \DateTime('now'); $this->published=false; } /** * Get id * * @return int */ public function getId() { return $this->id; } /** * Set way * * @param string $way * * @return Aregulation */ public function setWay($way) { $this->way = $way; return $this; } /** * Get way * * @return string */ public function getWay() { return $this->way; } /** * Set amount * * @param float $amount * * @return Aregulation */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Get amount * * @return float */ public function getAmount() { return $this->amount; } /** * Set docNumber * * @param string $docNumber * * @return Aregulation */ public function setDocNumber($docNumber) { $this->docNumber = $docNumber; return $this; } /** * Get docNumber * * @return string */ public function getDocNumber() { return $this->docNumber; } /** * Set cached * * * @return Aregulation */ public function setCached($cached) { $this->cached = $cached; return $this; } /** * Get cached * * @return bool */ public function getCached() { return $this->cached; } /** * Set intervenant * * * @return Aregulation */ public function setIntervenant(Intervenant $intervenant) { $this->intervenant = $intervenant; return $this; } /** * Get attribution * * @return Intervenant */ public function getIntervenant() { return $this->intervenant; } /** * Set initie * * * @return Aregulation */ public function setInitie(User $initie) { $this->initie = $initie; return $this; } /** * Get initie * * @return User */ public function getInitie() { return $this->initie; } public function getMonths(){ return $this->way; } public function getSchoolyear(): ?Schoolyear { return $this->schoolyear; } public function setSchoolyear(?Schoolyear $schoolyear): void { $this->schoolyear = $schoolyear; } public function getCreateAt(): \DateTime { if($this->createAt === null) return $this->getPublishedAt(); return $this->createAt; } public function __toString(): string { return 'Id:'.$this->id.'<br>'. 'Date:'.$this->getCreateAt()->format('d-m-Y').'<br>'. 'Formateur:'.$this->attribution->getIntervenant().'<br>'. 'Classe:'.$this->attribution->getClasse().'<br>'. 'Unite:'.$this->attribution->getUnite().'<br>'. 'Raison:'.$this->way.'<br>'. 'Montant: '.$this->getAmount().' DH<br>' ; }}