src/Entity/Activity.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActivityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassActivityRepository::class)]
  8. class Activity
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100uniquetrue)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length100uniquetrue)]
  17.     private ?string $slug null;
  18.     #[ORM\OneToMany(mappedBy'activity'targetEntityCustomer::class)]
  19.     private Collection $customers;
  20.     public function __construct()
  21.     {
  22.         $this->customers = new ArrayCollection();
  23.     }
  24.     public function __toString(): string
  25.     {
  26.         return $this->getName();
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getName(): ?string
  33.     {
  34.         return $this->name;
  35.     }
  36.     public function setName(string $name): self
  37.     {
  38.         $this->name $name;
  39.         return $this;
  40.     }
  41.     public function getSlug(): ?string
  42.     {
  43.         return $this->slug;
  44.     }
  45.     public function setSlug(string $slug): self
  46.     {
  47.         $this->slug $slug;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return Collection<int, Customer>
  52.      */
  53.     public function getCustomers(): Collection
  54.     {
  55.         return $this->customers;
  56.     }
  57.     public function addCustomer(Customer $customer): self
  58.     {
  59.         if (!$this->customers->contains($customer)) {
  60.             $this->customers->add($customer);
  61.             $customer->setActivity($this);
  62.         }
  63.         return $this;
  64.     }
  65.     public function removeCustomer(Customer $customer): self
  66.     {
  67.         if ($this->customers->removeElement($customer)) {
  68.             // set the owning side to null (unless already changed)
  69.             if ($customer->getActivity() === $this) {
  70.                 $customer->setActivity(null);
  71.             }
  72.         }
  73.         return $this;
  74.     }
  75. }