<?php
namespace Roothirsch\ShopBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Roothirsch\ShopBundle\Repository\DiscountRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
/**
* @ORM\Entity(repositoryClass=DiscountRepository::class)
* @ORM\Table(name="shop_discount")
* @ApiResource(
* attributes={
* "order"={"startDate": "DESC"}
* },
* normalizationContext={"groups"={"discount_read"}},
* denormalizationContext={"groups"={"discount_write"}},
* collectionOperations={
* "get"={"path"="/discounts"},
* "post"
* },
* itemOperations={
* "get",
* "put",
* "delete"
* }
* )
*/
class Discount implements Translatable
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"discount_read"})
*/
private $id;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=255)
* @Groups({"discount_read", "discount_write"})
*/
private $name;
/**
* @ORM\Column(type="float")
* @Groups({"discount_read", "discount_write"})
*/
private $value;
/**
* Helper text for the admin interface to indicate that discount values should be negative
*/
/**
* @ORM\Column(type="date")
* @Groups({"discount_read", "discount_write"})
*/
private $startDate;
/**
* @ORM\Column(type="date")
* @Groups({"discount_read", "discount_write"})
*/
private $endDate;
/**
* @ORM\Column(type="boolean")
* @Groups({"discount_read", "discount_write"})
*/
private $active = true;
/**
* @ORM\Column(type="string", length=255, options={"default"="percentageAfterDiscounts"})
* @Groups({"discount_read", "discount_write"})
*/
private $type = 'percentageAfterDiscounts';
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"discount_read", "discount_write"})
*/
private $category;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getValue(): ?float
{
return $this->value;
}
public function setValue(float $value): self
{
$this->value = $value;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
}