<?php
declare(strict_types=1);
namespace App\Point\Doctrine\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Point\Doctrine\Repository\PurchaseRepository;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\ManyToOne;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints\NotNull;
#[ApiResource(
collectionOperations: ['get', 'post'],
itemOperations: ['get' => ['security' => 'is_granted("item", object)']],
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']]
)]
#[Entity(repositoryClass: PurchaseRepository::class)]
class Purchase extends Transaction
{
#[ManyToOne(targetEntity: PaymentMethod::class)]
#[Groups(['read', 'write'])]
#[ApiProperty(readableLink: false, writableLink: false)]
private ?PaymentMethod $paymentMethod = null;
#[Column]
#[Groups('read')]
private string $state = 'pending';
#[Column(nullable: true)]
#[Groups(['read', 'write'])]
private ?string $internReference = null;
public function getPaymentMethod(): ?PaymentMethod
{
return $this->paymentMethod;
}
public function setPaymentMethod(?PaymentMethod $paymentMethod): void
{
$this->paymentMethod = $paymentMethod;
}
public function getState(): string
{
return $this->state;
}
public function setState(string $state): void
{
$this->state = $state;
}
public function getInternReference(): ?string
{
return $this->internReference;
}
public function setInternReference(?string $internReference): void
{
$this->internReference = $internReference;
}
}