src/Entity/Training/Fregulation.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Training;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\Schoolyear;
  5. use App\Entity\User;
  6. use App\Repository\Training\FregulationRepository;
  7. use App\Traits\Actions;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * Fregulation
  11.  */
  12. #[ORM\Entity(repositoryClassFregulationRepository::class)]
  13. #[ORM\Table(name'hs_tc_training_fregulation')]
  14. #[ApiResource]
  15. class Fregulation implements \Stringable
  16. {
  17.     use Actions;
  18.     #[ORM\ManyToOne(targetEntityFormer::class, inversedBy'regulations')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?Former $former null;
  21.     #[ORM\ManyToOne(targetEntityUser::class)]
  22.     #[ORM\JoinColumn(nullabletrue)]
  23.     private ?User $initie null;
  24.     /**
  25.      * @var string
  26.      */
  27.     #[ORM\Column(name'way'type'string'length255)]
  28.     private $way;
  29.     /**
  30.      * @var float
  31.      */
  32.     #[ORM\Column(name'amount'type'float')]
  33.     private $amount;
  34.     #[ORM\Column(name'doc_number'type'string'length255)]
  35.     private string $docNumber '11';
  36.     #[ORM\Column(name'cached'type'boolean')]
  37.     private bool $cached false;
  38.     #[ORM\ManyToOne(targetEntitySchoolyear::class)]
  39.     #[ORM\JoinColumn(nullabletrue)]
  40.     private ?Schoolyear $schoolyear null;
  41.     /**
  42.      * Fregulation constructor.
  43.      */
  44.     public function __construct()
  45.     {
  46.         // date_default_timezone_set('Africa/Casablanca');
  47.         $this->publishedAt=new \DateTime('now');
  48.         $this->createAt=new \DateTime('now');
  49.         $this->published=false;
  50.     }
  51.     /**
  52.      * Get id
  53.      *
  54.      * @return int
  55.      */
  56.     public function getId()
  57.     {
  58.         return $this->id;
  59.     }
  60.     /**
  61.      * Set way
  62.      *
  63.      * @param string $way
  64.      *
  65.      * @return Fregulation
  66.      */
  67.     public function setWay($way)
  68.     {
  69.         $this->way $way;
  70.         return $this;
  71.     }
  72.     /**
  73.      * Get way
  74.      *
  75.      * @return string
  76.      */
  77.     public function getWay()
  78.     {
  79.         return $this->way;
  80.     }
  81.     /**
  82.      * Set amount
  83.      *
  84.      * @param float $amount
  85.      *
  86.      * @return Fregulation
  87.      */
  88.     public function setAmount($amount)
  89.     {
  90.         $this->amount $amount;
  91.         return $this;
  92.     }
  93.     /**
  94.      * Get amount
  95.      *
  96.      * @return float
  97.      */
  98.     public function getAmount()
  99.     {
  100.         return $this->amount;
  101.     }
  102.     /**
  103.      * Set docNumber
  104.      *
  105.      * @param string $docNumber
  106.      *
  107.      * @return Fregulation
  108.      */
  109.     public function setDocNumber($docNumber)
  110.     {
  111.         $this->docNumber $docNumber;
  112.         return $this;
  113.     }
  114.     /**
  115.      * Get docNumber
  116.      *
  117.      * @return string
  118.      */
  119.     public function getDocNumber()
  120.     {
  121.         return $this->docNumber;
  122.     }
  123.     /**
  124.      * Set cached
  125.      *
  126.      *
  127.      * @return Fregulation
  128.      */
  129.     public function setCached($cached)
  130.     {
  131.         $this->cached $cached;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get cached
  136.      *
  137.      * @return bool
  138.      */
  139.     public function getCached()
  140.     {
  141.         return $this->cached;
  142.     }
  143.     /**
  144.      * Set former
  145.      *
  146.      *
  147.      * @return Fregulation
  148.      */
  149.     public function setFormer(Former $former)
  150.     {
  151.         $this->former $former;
  152.         return $this;
  153.     }
  154.     /**
  155.      * Get assignation
  156.      *
  157.      * @return Former
  158.      */
  159.     public function getFormer()
  160.     {
  161.         return $this->former;
  162.     }
  163.     /**
  164.      * Set initie
  165.      *
  166.      *
  167.      * @return Fregulation
  168.      */
  169.     public function setInitie(User $initie)
  170.     {
  171.         $this->initie $initie;
  172.         return $this;
  173.     }
  174.     /**
  175.      * Get initie
  176.      *
  177.      * @return User
  178.      */
  179.     public function getInitie()
  180.     {
  181.         return $this->initie;
  182.     }
  183.     public function getMonths(){
  184.         return $this->way;
  185.     }
  186.     public function getSchoolyear(): ?Schoolyear
  187.     {
  188.         return $this->schoolyear;
  189.     }
  190.     public function setSchoolyear(?Schoolyear $schoolyear): void
  191.     {
  192.         $this->schoolyear $schoolyear;
  193.     }
  194.     public function getCreateAt(): \DateTime
  195.     {
  196.         if($this->createAt === null) return $this->getPublishedAt();
  197.         return $this->createAt;
  198.     }
  199.     public function __toString(): string
  200.     {
  201.         return
  202.             'Id:'.$this->id.'<br>'.
  203.             'Date:'.$this->getCreateAt()->format('d-m-Y').'<br>'.
  204.             'Formateur:'.$this->assignation->getFormer().'<br>'.
  205.             'Groupe:'.$this->assignation->getGroupe().'<br>'.
  206.             'Module:'.$this->assignation->getModule().'<br>'.
  207.             'Raison:'.$this->way.'<br>'.
  208.             'Montant: '.$this->getAmount().' DH<br>'
  209.             ;
  210.     }
  211. }