src/Entity/Contrat.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContratRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=ContratRepository::class)
  7.  */
  8. class Contrat
  9. {
  10.     /**
  11.      * @ORM\Id
  12.      * @ORM\GeneratedValue
  13.      * @ORM\Column(type="integer")
  14.      */
  15.     private $id;
  16.     /**
  17.      * @ORM\Column(type="integer", nullable=true)
  18.      */
  19.     private $duree;
  20.     /**
  21.      * @ORM\Column(type="float", nullable=true)
  22.      */
  23.     private $valeur;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=User::class)
  26.      * @ORM\JoinColumn(nullable=true)
  27.      */
  28.     private $collaborateur;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Entreprise::class, inversedBy="contrats")
  31.      * @ORM\JoinColumn(nullable=false)
  32.      */
  33.     private $entreprise;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $pdl;
  38.     /**
  39.      * @ORM\Column(type="float", nullable=true, options={"default" : 0})
  40.      */
  41.     private $car 0;
  42.     /**
  43.      * @ORM\Column(type="float", nullable=true, options={"default" : 0})
  44.      */
  45.     private $prix_moyen 0;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $fournisseur;
  50.     /**
  51.      * @ORM\Column(type="date", nullable=true)
  52.      */
  53.     private $date_debut;
  54.     /**
  55.      * @ORM\Column(type="date", nullable=true)
  56.      */
  57.     private $date_fin;
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getDuree(): ?int
  63.     {
  64.         if ($this->date_debut && $this->date_fin) {
  65.             $interval $this->date_debut->diff($this->date_fin);
  66.             return $interval->12 $interval->m;
  67.         }
  68.         return $this->duree;
  69.     }
  70.     public function setDuree(?int $duree): self
  71.     {
  72.         $this->duree $duree;
  73.         return $this;
  74.     }
  75.     public function getValeur(): ?float
  76.     {
  77.         if ($this->car === null || $this->prix_moyen === null) {
  78.             return null;
  79.         }
  80.         return $this->car $this->prix_moyen;
  81.     }
  82.     public function setValeur(?float $valeur): self
  83.     {
  84.         $this->valeur $valeur;
  85.         return $this;
  86.     }
  87.     public function getCollaborateur(): ?User
  88.     {
  89.         return $this->collaborateur;
  90.     }
  91.     public function setCollaborateur(?User $collaborateur): self
  92.     {
  93.         $this->collaborateur $collaborateur;
  94.         return $this;
  95.     }
  96.     public function getEntreprise(): ?Entreprise
  97.     {
  98.         return $this->entreprise;
  99.     }
  100.     public function setEntreprise(?Entreprise $entreprise): self
  101.     {
  102.         $this->entreprise $entreprise;
  103.         return $this;
  104.     }
  105.     public function getPdl(): ?string
  106.     {
  107.         return $this->pdl;
  108.     }
  109.     public function setPdl(?string $pdl): self
  110.     {
  111.         $this->pdl $pdl;
  112.         return $this;
  113.     }
  114.     public function getCar(): ?float
  115.     {
  116.         return $this->car;
  117.     }
  118.     public function setCar(?float $car): self
  119.     {
  120.         $this->car $car ?? 0;
  121.         return $this;
  122.     }
  123.     public function getPrixMoyen(): ?float
  124.     {
  125.         return $this->prix_moyen;
  126.     }
  127.     public function setPrixMoyen(?float $prix_moyen): self
  128.     {
  129.         $this->prix_moyen $prix_moyen ?? 0;
  130.         return $this;
  131.     }
  132.     public function getFournisseur(): ?string
  133.     {
  134.         return $this->fournisseur;
  135.     }
  136.     public function setFournisseur(?string $fournisseur): self
  137.     {
  138.         $this->fournisseur $fournisseur;
  139.         return $this;
  140.     }
  141.     public function getDateDebut(): ?\DateTimeInterface
  142.     {
  143.         return $this->date_debut;
  144.     }
  145.     public function setDateDebut(?\DateTimeInterface $date_debut): self
  146.     {
  147.         $this->date_debut $date_debut;
  148.         return $this;
  149.     }
  150.     public function getDateFin(): ?\DateTimeInterface
  151.     {
  152.         return $this->date_fin;
  153.     }
  154.     public function setDateFin(?\DateTimeInterface $date_fin): self
  155.     {
  156.         $this->date_fin $date_fin;
  157.         return $this;
  158.     }
  159. }