<?php
namespace App\Entity;
use App\Repository\CustomerRepository;
use App\Service\RoleService;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CustomerRepository::class)
* @method self setStatus(bool $status)
*/
class Customer extends User
{
/**
* @ORM\OneToMany(targetEntity=Praying::class, mappedBy="customer")
*/
private $prayings;
public function __construct()
{
parent::__construct();
$this->setRoles([RoleService::ROLE_CUSTOMER]);
$this->prayings = new ArrayCollection();
}
public function __toString(): string
{
return $this->getFullName();
}
/**
* @return Collection<int, Praying>
*/
public function getPrayings(): Collection
{
return $this->prayings;
}
public function addPraying(Praying $praying): self
{
if (!$this->prayings->contains($praying)) {
$this->prayings[] = $praying;
$praying->setCustomer($this);
}
return $this;
}
public function removePraying(Praying $praying): self
{
if ($this->prayings->removeElement($praying)) {
// set the owning side to null (unless already changed)
if ($praying->getCustomer() === $this) {
$praying->setCustomer(null);
}
}
return $this;
}
/**
* @return Collection<int, Prayer|null>
*/
public function getParticipatedPrayers(): Collection
{
return $this->getPrayings()->map(function (Praying $praying) {
return $praying->getPrayer();
});
}
}