src/Entity/Customer/Customer.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Customer;
  4. use App\Entity\Giftcard;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Sylius\Component\Core\Model\Customer as BaseCustomer;
  9. use App\Controller;
  10. use App\Service\FideliumService;
  11. /**
  12.  * @ORM\Entity
  13.  * @ORM\Table(name="sylius_customer")
  14.  */
  15. class Customer extends BaseCustomer
  16. {
  17.     /**
  18.      * @ORM\OneToMany(targetEntity=Giftcard::class, mappedBy="customer_id")
  19.      */
  20.     private $giftcards;
  21.     public function __construct()
  22.     {
  23.         parent::__construct();
  24.         $this->giftcards = new ArrayCollection();
  25.     }
  26.     /** @ORM\Column(type="string", nullable=true) */
  27.     private $fideliumcard;
  28.     public function getFideliumcard(): ?string
  29.     {
  30.         return $this->fideliumcard;
  31.     }
  32.     public function setFideliumcard(?string $fideliumcard): void
  33.     {
  34.         $this->fideliumcard $fideliumcard;
  35.     } 
  36.   
  37.     public function getStatusFideliumcard(): ?string
  38.     {
  39.         $fideliumcard $this->getFideliumcard();
  40.         if (isset($fideliumcard) && !empty($fideliumcard))
  41.         {
  42.             $fs = new FideliumService ($fideliumcard);        
  43.             return $fs->getStatusCard ();
  44.         }
  45.         else
  46.             return "0";
  47.     }
  48.     
  49.     /**
  50.      * @return Collection|Giftcard[]
  51.      */
  52.     public function getGiftcards(): Collection
  53.     {
  54.         return $this->giftcards;
  55.     }
  56.     public function addGiftcard(Giftcard $giftcard): self
  57.     {
  58.         if (!$this->giftcards->contains($giftcard)) {
  59.             $this->giftcards[] = $giftcard;
  60.             $giftcard->setCustomerId($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeGiftcard(Giftcard $giftcard): self
  65.     {
  66.         if ($this->giftcards->removeElement($giftcard)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($giftcard->getCustomerId() === $this) {
  69.                 $giftcard->setCustomerId(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }   
  74. }