src/Entity/Order.php line 20
<?php
namespace App\Entity;
use App\Repository\OrderRepository;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Gedmo\Blameable\Traits\BlameableEntity;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
#[ORM\Entity(repositoryClass: OrderRepository::class)]
#[ORM\Table(name: '`order`')]
#[ApiResource]
#[ApiFilter(SearchFilter::class, properties: ["user" => "exact"])]
class Order
{
use BlameableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups([
'order_get',
'order_getc',
'user_get_me'
])]
private ?int $id = null;
#[ORM\Column]
#[Groups([
'order_get',
'order_getc',
'order_post',
'user_get_me'
])]
private ?int $quantity = null;
#[ORM\Column]
#[Groups([
'order_get', 'order_getc', 'order_post',
'user_get_me'
])]
private ?float $price = null;
#[ORM\ManyToOne(
targetEntity: User::class,
inversedBy: 'orders',
fetch: 'EAGER'
)
]
#[ORM\JoinColumn(nullable: false)]
#[Groups([
'order_get',
'order_getc',
'order_post',
'order_put',
'user_get_me',
'user_get'
])]
#[Assert\NotNull(groups: [ 'order_post', 'order_put' ])]
private ?User $user = null;
#[ORM\Column]
#[Groups([
'order_get', 'order_getc', 'order_post', 'user_get_me'
])]
private ?DateTime $createdAt = null;
#[ORM\Column]
#[Groups([
'order_get', 'order_getc', 'order_post', 'order_put', 'user_get_me'
])]
private ?bool $isPayed = null;
public function __construct()
{
$this->createdAt = new DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(int $quantity): static
{
$this->quantity = $quantity;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): static
{
$this->price = $price;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
public function setCreatedAt(DateTime $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function isIsPayed(): ?bool
{
return $this->isPayed;
}
public function setIsPayed(bool $isPayed): static
{
$this->isPayed = $isPayed;
return $this;
}
}