Voici votre URL de partage https://sharemycode.io/c/14965f02e6 (Cliquer pour copier) (Copié)

<?php

namespace App\Entity;

use App\Repository\FiltersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * @ORM\Entity(repositoryClass=FiltersRepository::class)
 * @UniqueEntity(
 * fields= {"name"},
 * message= "Ce filtre a déjà été créé !"
 * )
 */
class Filters
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=50)
     */
    private $name;

    /**
     * @ORM\ManyToMany(targetEntity=ListingProjects::class, mappedBy="name")
     */
    private $listingProjects;

    public function __construct()
    {
        $this->listingProjects = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return Collection<int, ListingProjects>
     */
    public function getListingProjects(): Collection
    {
        return $this->listingProjects;
    }

    public function addListingProject(ListingProjects $listingProject): self
    {
        if (!$this->listingProjects->contains($listingProject)) {
            $this->listingProjects[] = $listingProject;
            $listingProject->addName($this);
        }

        return $this;
    }

    public function removeListingProject(ListingProjects $listingProject): self
    {
        if ($this->listingProjects->removeElement($listingProject)) {
            $listingProject->removeName($this);
        }

        return $this;
    }


}

Informations

Cet extrait a été créé le 24 nov. 2022 à 16:42:36

Cet extrait expire le 24 déc. 2022 à 16:42:36

Langage : php

Logo php

Code ajouté par KaeligB

Link

Voici votre URL de partage : https://sharemycode.io/c/14965f02e6 Copié