src/Entity/Coupons.php line 24
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use App\Repository\CouponsRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;#[ORM\Entity(repositoryClass: CouponsRepository::class)]#[ApiResource(normalizationContext: ['groups' => ['coupon:read']],denormalizationContext: ['groups' => ['coupon:write']],order: ['id' => 'DESC'],)]#[ApiFilter(SearchFilter::class, properties: ['code' => 'exact'])]class Coupons{#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Column(length: 255)]private ?string $name = null;#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Column(length: 255)]private ?string $code = null;#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $description = null;#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Column(nullable: true)]private ?float $sum = null;#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Column(nullable: true)]private ?float $percent = null;#[Groups(['coupon:read', 'coupon:write'])]#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'coupons')]private Collection $category;#[Groups(['coupon:read', 'coupon:write', 'cat:read'])]#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'coupons')]private Collection $users;#[Groups(['coupon:read', 'coupon:write', 'cat:read'])]#[ORM\OneToMany(mappedBy: 'coupons', targetEntity: PreOrder::class)]private Collection $pre_orders;#[Groups(['coupon:read', 'coupon:write', 'pre_order:read','cat:read'])]#[ORM\Column(length: 100, nullable: true)]private ?string $status = null;public function __construct(){$this->category = new ArrayCollection();$this->users = new ArrayCollection();$this->pre_orders = new ArrayCollection();}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 getCode(): ?string{return $this->code;}public function setCode(string $code): self{$this->code = $code;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getSum(): ?float{return $this->sum;}public function setSum(?float $sum): self{$this->sum = $sum;return $this;}public function getPercent(): ?float{return $this->percent;}public function setPercent(?float $percent): self{$this->percent = $percent;return $this;}/*** @return Collection<int, Category>*/public function getCategory(): Collection{return $this->category;}public function addCategory(Category $category): self{if (!$this->category->contains($category)) {$this->category->add($category);}return $this;}public function removeCategory(Category $category): self{$this->category->removeElement($category);return $this;}/*** @return Collection<int, User>*/public function getUsers(): Collection{return $this->users;}public function addUser(User $user): self{if (!$this->users->contains($user)) {$this->users->add($user);}return $this;}public function removeUser(User $user): self{$this->users->removeElement($user);return $this;}/*** @return Collection<int, PreOrder>*/public function getPreOrders(): Collection{return $this->pre_orders;}public function addPreOrder(PreOrder $preOrder): self{if (!$this->pre_orders->contains($preOrder)) {$this->pre_orders->add($preOrder);$preOrder->setCoupons($this);}return $this;}public function removePreOrder(PreOrder $preOrder): self{if ($this->pre_orders->removeElement($preOrder)) {// set the owning side to null (unless already changed)if ($preOrder->getCoupons() === $this) {$preOrder->setCoupons(null);}}return $this;}public function getStatus(): ?string{return $this->status;}public function setStatus(?string $status): static{$this->status = $status;return $this;}}