From 4accca2c57b5f12169afe6a75c74efadd86d835d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 8 Jul 2025 16:30:10 +0200 Subject: =?UTF-8?q?acc=C3=A8s=20instances=20depuis=20Prestation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/CESU.php | 11 +++++++++-- src/model/entities/Devis.php | 7 +++++-- src/model/entities/Facture.php | 11 +++++++++-- src/model/entities/Location.php | 15 +++++++++++++-- src/model/entities/Prestation.php | 31 +++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 8 deletions(-) (limited to 'src/model') diff --git a/src/model/entities/CESU.php b/src/model/entities/CESU.php index 09a2542..de3a359 100644 --- a/src/model/entities/CESU.php +++ b/src/model/entities/CESU.php @@ -13,9 +13,12 @@ class CESU #[ORM\GeneratedValue] private int|null $id = null; - #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] + //~ private Prestation|null $presta = null; + #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'cesu', cascade: ['persist'])] #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private Prestation|null $presta = null; + private ?Prestation $presta = null; #[ORM\Column] private string $taches; @@ -39,6 +42,10 @@ class CESU { return $this->presta; } + public function getSalaire(): float + { + return $this->salaire; + } public function getAllWithWindowFields(): array { diff --git a/src/model/entities/Devis.php b/src/model/entities/Devis.php index 99589e7..8518f8e 100644 --- a/src/model/entities/Devis.php +++ b/src/model/entities/Devis.php @@ -13,9 +13,12 @@ class Devis #[ORM\GeneratedValue] private int|null $id = null; - #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] + //~ private Prestation|null $presta = null; + #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'devis', cascade: ['persist'])] #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private Prestation|null $presta = null; + private ?Prestation $presta = null; #[ORM\Column] private string $taches; diff --git a/src/model/entities/Facture.php b/src/model/entities/Facture.php index 3a8a551..75d1a6e 100644 --- a/src/model/entities/Facture.php +++ b/src/model/entities/Facture.php @@ -13,9 +13,12 @@ class Facture #[ORM\GeneratedValue] private int|null $id = null; - #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] + //~ private Prestation|null $presta = null; + #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'facture', cascade: ['persist'])] #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private Prestation|null $presta = null; + private ?Prestation $presta = null; #[ORM\Column] private string $taches; @@ -58,6 +61,10 @@ class Facture // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés return get_object_vars($this); } + public function getTotalMainDOeuvre(): float + { + return $this->total_main_d_oeuvre; + } public function getAllWithWindowFields(): array { diff --git a/src/model/entities/Location.php b/src/model/entities/Location.php index 7ce6f0d..b3c2f8a 100644 --- a/src/model/entities/Location.php +++ b/src/model/entities/Location.php @@ -13,9 +13,12 @@ class Location #[ORM\GeneratedValue] private int|null $id = null; - #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] + //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] + //~ private Prestation|null $presta = null; + #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'location', cascade: ['persist'])] #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private Prestation|null $presta = null; + private ?Prestation $presta = null; #[ORM\Column] protected string $designation; @@ -51,6 +54,14 @@ class Location { return $this->presta; } + public function getLoyer(): float + { + return $this->loyer_hebdo; + } + public function getLoyersPayes(): int + { + return $this->loyers_payes; + } public function getAll(): array { // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés diff --git a/src/model/entities/Prestation.php b/src/model/entities/Prestation.php index 6d014d8..ce98911 100644 --- a/src/model/entities/Prestation.php +++ b/src/model/entities/Prestation.php @@ -27,6 +27,15 @@ class Prestation private string $mode_paiement = ''; // non renseigné quand on fait un devis #[ORM\Column] private string $commentaires; + + #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Facture::class)] + private ?facture $facture = null; + #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Devis::class)] + private ?devis $devis; + #[ORM\OneToOne(mappedBy: 'presta', targetEntity: CESU::class)] + private ?cesu $cesu; + #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Location::class)] + private ?location $location; public static EntityManager $entityManager; @@ -56,6 +65,10 @@ class Prestation { return $this->type_presta; } + public function getModePaiement(): string + { + return $this->mode_paiement; + } public function getClient(): Client { return $this->client; @@ -79,6 +92,24 @@ class Prestation "Commentaires:" => $this->commentaires]; } + // une interface pour ça c'est bien aussi non? + public function getFacture(): ?Facture + { + return $this->facture; + } + public function getDevis(): ?Devis + { + return $this->devis; + } + public function getCesu(): ?CESU + { + return $this->cesu; + } + public function getLocation(): ?Location + { + return $this->location; + } + // setters //~ public function setCodePresta(string $value) //~ { -- cgit v1.2.3