src/Entity/Activity.php line 11
<?php
namespace App\Entity;
use App\Repository\ActivityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ActivityRepository::class)]
class Activity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 100, unique: true)]
private ?string $name = null;
#[ORM\Column(length: 100, unique: true)]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'activity', targetEntity: Customer::class)]
private Collection $customers;
public function __construct()
{
$this->customers = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
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;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Customer>
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(Customer $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers->add($customer);
$customer->setActivity($this);
}
return $this;
}
public function removeCustomer(Customer $customer): self
{
if ($this->customers->removeElement($customer)) {
// set the owning side to null (unless already changed)
if ($customer->getActivity() === $this) {
$customer->setActivity(null);
}
}
return $this;
}
}