<?php
namespace App\Entity\Training;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Training\NotemoduleRepository;
use App\Traits\Actions;
use App\Entity\Training\Groupe;
use App\Entity\Training\Module;
use App\Entity\Training\Noteassign;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NotemoduleRepository::class)]
#[ORM\Table(name: 'hs_tc_training_notemodule')]
#[ApiResource]
class Notemodule
{
use Actions;
#[ORM\Column(name: "name", type: "string", length: 255)]
private string $name;
#[ORM\ManyToOne(targetEntity: Module::class, inversedBy: "notes")]
#[ORM\JoinColumn(nullable: false)]
private Module $module;
#[ORM\Column(name: "genre", type: "string", length: 255)]
private string $genre;
#[ORM\OneToMany(mappedBy: "notemodule", targetEntity: "Noteassign", cascade: ["persist"], orphanRemoval: true)]
private Collection $lines;
#[ORM\Column(type: 'boolean')]
private $deleted;
public function __construct()
{
// date_default_timezone_set('Africa/Casablanca');
$this->createAt=new \DateTime('now');
$this->published=false;
}
/**
* @return Module
*/
public function getModule(): ?Module
{
return $this->module;
}
/**
* @param Module $module
*/
public function setModule(?Module $module): Notemodule
{
$this->module = $module;
return $this;
}
/**
* @return string
*/
public function getGenre(): ?string
{
return $this->genre;
}
/**
* @param string $genre
*/
public function setGenre(?string $genre): Notemodule
{
$this->genre = $genre;
return $this;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(?string $name): Notemodule
{
$this->name = $name;
return $this;
}
/**
* Add line
*
*
* @return Notemodule
*/
public function addLine(Noteassign $line)
{
$line->setNotemodule($this);
$this->lines[] = $line;
return $this;
}
/**
* Remove line
*/
public function removeLine(Noteassign $line)
{
$this->lines->removeElement($line);
}
/**
* Get lines
*
* @return Collection
*/
public function getLines()
{
return $this->lines;
}
public function getNameTxt(){
$choices=[
'c1'=>'Contrôle 1',
'c2'=>'Contrôle 2',
'c3'=>'Contrôle 3',
'c4'=>'Contrôle 4',
/* 'c5'=>'Contrôle 5',*/
'ep'=>'Examen pratique',
'et'=>'Examen théorique',
];
return$choices[$this->name];
}
/**
* @return bool
*/
public function isDeleted()
{
return $this->deleted;
}
/**
* @param bool $deleted
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
}