<?php
/*
* This file is part of the kProjet project.
*
* (c) Kodiom <info@kodiom.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Client;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Repository\CardRepository;
/**
* Card
*
* @ORM\Table()
* @ORM\Entity(repositoryClass=CardRepository::class)
*
* @ApiResource(
* attributes={
* "filters"={"card.search"},
* "force_eager"=false,
* "normalization_context"={"groups"={"read", "user", "media", "client"}},
* "denormalization_context"={"groups"={"read", "user", "media"}}
* },
* collectionOperations={
* "get"={"method"="GET"},
* "post"={"route_name"="api_cards_post_collection"}
* }
* )
*/
class Card
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"read"})
*/
private $id;
/**
* Payment intend ID => TODO: payment id
* @var string
*
* @ORM\Column(type="string", length=200, nullable=true)
* @Groups({"read"})
*/
private $token;
/**
*
* Payment method ID => TODO: rename field
* @var string
*
* @ORM\Column(type="string", length=200, nullable=true)
* @Groups({"read"})
*/
private $cardToken;
/**
* Customer Stripe ID => TODO: Rename field..
*
* @ORM\Column(type="string", length=200, nullable=true)
* @Groups({"read"})
*/
private $customerToken;
/**
* @var string
*
* @ORM\Column(type="string", length=10, nullable=true)
*
* @Assert\NotBlank()
* @Groups({"read"})
*/
private $lastDigit;
/**
* @var sca
* Répresnete le novueau format des cartes
* @ORM\Column(type="boolean")
*
* @Groups({"read"})
*/
private $sca = 1;
/**
* @var Client
*
* @ORM\ManyToOne(
* targetEntity=Client::class
* )
* @Groups({"read"})
*/
private $client;
public function __toString()
{
return ($this->getToken()) ? $this->getToken() : '';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get token
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
* Set token
*
* @param string $token
*
* @return Card
*/
public function setToken($token)
{
$this->token = $token;
return $this;
}
/**
* Get cardToken
*
* @return string
*/
public function getCardToken()
{
return $this->cardToken;
}
/**
* Set cardToken
*
* @param string $cardToken
*
* @return Card
*/
public function setCardToken($cardToken)
{
$this->cardToken = $cardToken;
return $this;
}
/**
* Get customerToken
*
* @return string
*/
public function getCustomerToken()
{
return $this->customerToken;
}
/**
* Set customerToken
*
* @param string $customerToken
*
* @return Card
*/
public function setCustomerToken($customerToken)
{
$this->customerToken = $customerToken;
return $this;
}
/**
* Get lastDigit
*
* @return string
*/
public function getLastDigit()
{
return $this->lastDigit;
}
/**
* Set lastDigit
*
* @param string $lastDigit
*
* @return Card
*/
public function setLastDigit($lastDigit)
{
$this->lastDigit = $lastDigit;
return $this;
}
/**
* Get client
*
* @return Client
*/
public function getClient()
{
return $this->client;
}
/**
* Set client
*
* @param Client $client
*
* @return Card
*/
public function setClient(?Client $client)
{
$this->client = $client;
return $this;
}
/**
* @return sca
*/
public function getSca()
{
return $this->sca;
}
/**
* @param sca $sca
*/
public function setSca($sca)
{
$this->sca = $sca;
}
}