src/Entity/Contract.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\isActif;
  4. use App\Entity\Trait\isTimestamstable;
  5. use App\Repository\ContractRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Doctrine\ORM\Mapping\JoinTable;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. /**
  12.  * @ORM\Entity(repositoryClass=ContractRepository::class)
  13.  * @ORM\HasLifecycleCallbacks
  14.  * @UniqueEntity("slug")
  15.  */
  16. class Contract
  17. {
  18.     use isActif;
  19.     use isTimestamstable;
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=180)
  28.      */
  29.     private $metric;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Valorization::class, inversedBy="contracts")
  32.      */
  33.     private $valorization;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=Collect::class, mappedBy="contract")
  36.      */
  37.     private $collects;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=Enterprise::class, inversedBy="contracts")
  40.      * @ORM\JoinColumn(nullable=false)
  41.      */
  42.     private $enterprise;
  43.     /**
  44.      * @ORM\ManyToMany(targetEntity=Provider::class, inversedBy="contracts")
  45.      * @JoinTable(name="Contract_Has_Provider")
  46.      */
  47.     private $providers;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity=ContractHasEquipment::class, mappedBy="contract")
  50.      */
  51.     private $equipments;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Ticket::class, mappedBy="contract")
  54.      */
  55.     private $tickets;
  56.     /**
  57.      * @ORM\Column(type="datetime")
  58.      */
  59.     private $startedAt;
  60.     /**
  61.      * @ORM\Column(type="datetime", nullable=true)
  62.      */
  63.     private $endedAt;
  64.     /**
  65.      * @ORM\Column(type="float")
  66.      */
  67.     private $price;
  68.     /**
  69.      * @ORM\Column(type="float")
  70.      */
  71.     private $commission;
  72.     /**
  73.      * @ORM\Column(type="string", length=255)
  74.      */
  75.     private $name;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="contracts")
  78.      */
  79.     private $user;
  80.     /**
  81.      * @ORM\ManyToOne(targetEntity=WasteType::class, inversedBy="contracts")
  82.      */
  83.     private $waste;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, unique=true)
  86.      */
  87.     private $slug;
  88.     /**
  89.      * @ORM\Column(type="string", length=255)
  90.      */
  91.     private $periodicity;
  92.     /**
  93.      * @ORM\Column(type="float", nullable=true)
  94.      */
  95.     private $levage;
  96.     /**
  97.      * @ORM\Column(type="string", length=4)
  98.      */
  99.     private $currency;
  100.     public function __construct()
  101.     {
  102.         $this->collects = new ArrayCollection();
  103.         $this->providers = new ArrayCollection();
  104.         $this->equipments = new ArrayCollection();
  105.         $this->tickets = new ArrayCollection();
  106.     }
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     /**
  112.      * @return mixed
  113.      */
  114.     public function getMetric()
  115.     {
  116.         return $this->metric;
  117.     }
  118.     /**
  119.      * @param mixed $metric
  120.      */
  121.     public function setMetric($metric): void
  122.     {
  123.         $this->metric $metric;
  124.     }
  125.     public function getValorization(): ?Valorization
  126.     {
  127.         return $this->valorization;
  128.     }
  129.     public function setValorization(?Valorization $valorization): self
  130.     {
  131.         $this->valorization $valorization;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return Collection|Collect[]
  136.      */
  137.     public function getCollects(): Collection
  138.     {
  139.         return $this->collects;
  140.     }
  141.     public function addCollect(Collect $collect): self
  142.     {
  143.         if (! $this->collects->contains($collect)) {
  144.             $this->collects[] = $collect;
  145.             $collect->setContract($this);
  146.         }
  147.         return $this;
  148.     }
  149.     public function removeCollect(Collect $collect): self
  150.     {
  151.         if ($this->collects->removeElement($collect)) {
  152.             // set the owning side to null (unless already changed)
  153.             if ($collect->getContract() === $this) {
  154.                 $collect->setContract(null);
  155.             }
  156.         }
  157.         return $this;
  158.     }
  159.     public function getEnterprise(): ?Enterprise
  160.     {
  161.         return $this->enterprise;
  162.     }
  163.     public function setEnterprise(?Enterprise $enterprise): self
  164.     {
  165.         $this->enterprise $enterprise;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return Collection|Provider[]
  170.      */
  171.     public function getProviders(): Collection
  172.     {
  173.         return $this->providers;
  174.     }
  175.     public function addProvider(Provider $provider): self
  176.     {
  177.         if (! $this->providers->contains($provider)) {
  178.             $this->providers[] = $provider;
  179.         }
  180.         return $this;
  181.     }
  182.     public function removeProvider(Provider $provider): self
  183.     {
  184.         $this->providers->removeElement($provider);
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection|ContractHasEquipment[]
  189.      */
  190.     public function getEquipments(): Collection
  191.     {
  192.         return $this->equipments;
  193.     }
  194.     public function addEquipment(ContractHasEquipment $equipment): self
  195.     {
  196.         if (! $this->equipments->contains($equipment)) {
  197.             $this->equipments[] = $equipment;
  198.             $equipment->setContract($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeEquipment(ContractHasEquipment $equipment): self
  203.     {
  204.         if ($this->equipments->removeElement($equipment)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($equipment->getContract() === $this) {
  207.                 $equipment->setContract(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection|Ticket[]
  214.      */
  215.     public function getTickets(): Collection
  216.     {
  217.         return $this->tickets;
  218.     }
  219.     public function addTicket(Ticket $ticket): self
  220.     {
  221.         if (! $this->tickets->contains($ticket)) {
  222.             $this->tickets[] = $ticket;
  223.             $ticket->setContract($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeTicket(Ticket $ticket): self
  228.     {
  229.         if ($this->tickets->removeElement($ticket)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($ticket->getContract() === $this) {
  232.                 $ticket->setContract(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     public function getStartedAt(): ?\DateTime
  238.     {
  239.         return $this->startedAt;
  240.     }
  241.     public function setStartedAt(\DateTime $startedAt): self
  242.     {
  243.         $this->startedAt $startedAt;
  244.         return $this;
  245.     }
  246.     public function getEndedAt(): ?\DateTime
  247.     {
  248.         return $this->endedAt;
  249.     }
  250.     public function setEndedAt(?\DateTime $endedAt): self
  251.     {
  252.         $this->endedAt $endedAt;
  253.         return $this;
  254.     }
  255.     public function getPrice(): ?float
  256.     {
  257.         return $this->price;
  258.     }
  259.     public function setPrice(float $price): self
  260.     {
  261.         $this->price $price;
  262.         return $this;
  263.     }
  264.     public function getCommission(): ?float
  265.     {
  266.         return $this->commission;
  267.     }
  268.     public function setCommission(float $commission): self
  269.     {
  270.         $this->commission $commission;
  271.         return $this;
  272.     }
  273.     public function getName(): ?string
  274.     {
  275.         return $this->name;
  276.     }
  277.     public function setName(string $name): self
  278.     {
  279.         $this->name $name;
  280.         return $this;
  281.     }
  282.     public function getUser(): ?User
  283.     {
  284.         return $this->user;
  285.     }
  286.     public function setUser(?User $user): self
  287.     {
  288.         $this->user $user;
  289.         return $this;
  290.     }
  291.     public function __toString(): string
  292.     {
  293.         return $this->getName();
  294.     }
  295.     public function getWaste(): ?WasteType
  296.     {
  297.         return $this->waste;
  298.     }
  299.     public function setWaste(?WasteType $waste): self
  300.     {
  301.         $this->waste $waste;
  302.         return $this;
  303.     }
  304.     public function getSlug(): ?string
  305.     {
  306.         return $this->slug;
  307.     }
  308.     public function setSlug(string $slug): self
  309.     {
  310.         $this->slug $slug;
  311.         return $this;
  312.     }
  313.     public function getPeriodicity(): ?string
  314.     {
  315.         return $this->periodicity;
  316.     }
  317.     public function setPeriodicity(string $periodicity): self
  318.     {
  319.         $this->periodicity $periodicity;
  320.         return $this;
  321.     }
  322.     public function getLevage(): ?float
  323.     {
  324.         return $this->levage;
  325.     }
  326.     public function setLevage(?float $levage): self
  327.     {
  328.         $this->levage $levage;
  329.         return $this;
  330.     }
  331.     public function getCurrency(): ?string
  332.     {
  333.         return $this->currency;
  334.     }
  335.     public function setCurrency(string $currency): self
  336.     {
  337.         $this->currency $currency;
  338.         return $this;
  339.     }
  340. }