<?phpnamespace App\Entity;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;use Doctrine\Common\Collections\Criteria;use App\Repository\ClientRepository;#[ORM\Entity(repositoryClass: ClientRepository::class)]#[ORM\Table(name: '`client`')]#[ORM\HasLifecycleCallbacks()]class Client{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[ORM\Column(type: 'string', length: 255, nullable:true)] private $nom; #[ORM\Column(type: 'boolean', length: 255, nullable:true)] private $isActif; #[ORM\ManyToMany(targetEntity:"Contact", inversedBy:"clients")] #[ORM\JoinTable(name:"contact_client")] private $contacts; #[ORM\OneToMany(targetEntity:"Projet", mappedBy:"client", cascade:["all"])] private $projets; public function __construct() { $this->contacts = new \Doctrine\Common\Collections\ArrayCollection(); $this->projets = new \Doctrine\Common\Collections\ArrayCollection(); } public function __toString(){ return $this->getNom(); } public function getId() { return $this->id; } public function setNom($nom) { $this->nom = $nom; return $this; } public function getNom() { return $this->nom; } public function setIsActif($is_actif) { $this->isActif = $is_actif; return $this; } public function getIsActif() { return $this->isActif; } public function setContacts($contacts) { $this->contacts = $contacts; return $this; } public function getContacts() { return $this->contacts; } public function clearContacts() { return $this->contacts->clear(); } public function addContact(Contact $contact) { $this->contacts->add($contact); $contact->getClients()->add($this); return $this; } public function hasContact(Contact $contact){ return in_array($contact, $this->getContacts()->toArray()); } public function removeContact(Contact $contact) { $this->contacts->removeElement($contact); $contact->getClients()->removeElement($this); return $this; } public function getProjets() { return $this->projets; } public function getProjetsActifs() { $criteria = Criteria::create()->where(Criteria::expr()->in("lastEtat", [2])); $contents = $this->getProjets()->matching($criteria); return $contents; } public function addProjet(Projet $projet) { $this->projets->add($projet); return $this; } public function removeProjet(Projet $projet) { $this->projets->remove($projet); return $this; }}