<?phpnamespace App\Entity\Training;use ApiPlatform\Core\Annotation\ApiResource;use App\Entity\Schoolyear;use App\Entity\User;use App\Repository\Training\FregulationRepository;use App\Traits\Actions;use Doctrine\ORM\Mapping as ORM;/** * Fregulation */#[ORM\Entity(repositoryClass: FregulationRepository::class)]#[ORM\Table(name: 'hs_tc_training_fregulation')]#[ApiResource]class Fregulation implements \Stringable{ use Actions; #[ORM\ManyToOne(targetEntity: Former::class, inversedBy: 'regulations')] #[ORM\JoinColumn(nullable: false)] private ?Former $former = 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; /** * Fregulation 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 Fregulation */ 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 Fregulation */ 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 Fregulation */ public function setDocNumber($docNumber) { $this->docNumber = $docNumber; return $this; } /** * Get docNumber * * @return string */ public function getDocNumber() { return $this->docNumber; } /** * Set cached * * * @return Fregulation */ public function setCached($cached) { $this->cached = $cached; return $this; } /** * Get cached * * @return bool */ public function getCached() { return $this->cached; } /** * Set former * * * @return Fregulation */ public function setFormer(Former $former) { $this->former = $former; return $this; } /** * Get assignation * * @return Former */ public function getFormer() { return $this->former; } /** * Set initie * * * @return Fregulation */ 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->assignation->getFormer().'<br>'. 'Groupe:'.$this->assignation->getGroupe().'<br>'. 'Module:'.$this->assignation->getModule().'<br>'. 'Raison:'.$this->way.'<br>'. 'Montant: '.$this->getAmount().' DH<br>' ; }}