<?php
declare(strict_types=1);
namespace App\Entity\Customer;
use App\Entity\Giftcard;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
use App\Controller;
use App\Service\FideliumService;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_customer")
*/
class Customer extends BaseCustomer
{
/**
* @ORM\OneToMany(targetEntity=Giftcard::class, mappedBy="customer_id")
*/
private $giftcards;
public function __construct()
{
parent::__construct();
$this->giftcards = new ArrayCollection();
}
/** @ORM\Column(type="string", nullable=true) */
private $fideliumcard;
public function getFideliumcard(): ?string
{
return $this->fideliumcard;
}
public function setFideliumcard(?string $fideliumcard): void
{
$this->fideliumcard = $fideliumcard;
}
public function getStatusFideliumcard(): ?string
{
$fideliumcard = $this->getFideliumcard();
if (isset($fideliumcard) && !empty($fideliumcard))
{
$fs = new FideliumService ($fideliumcard);
return $fs->getStatusCard ();
}
else
return "0";
}
/**
* @return Collection|Giftcard[]
*/
public function getGiftcards(): Collection
{
return $this->giftcards;
}
public function addGiftcard(Giftcard $giftcard): self
{
if (!$this->giftcards->contains($giftcard)) {
$this->giftcards[] = $giftcard;
$giftcard->setCustomerId($this);
}
return $this;
}
public function removeGiftcard(Giftcard $giftcard): self
{
if ($this->giftcards->removeElement($giftcard)) {
// set the owning side to null (unless already changed)
if ($giftcard->getCustomerId() === $this) {
$giftcard->setCustomerId(null);
}
}
return $this;
}
}