add api platform to entitites

This commit is contained in:
Tykayn 2025-02-14 14:35:21 +01:00 committed by tykayn
parent c44ac9c522
commit 9c9f8984af
15 changed files with 13 additions and 369 deletions

View file

@ -1,50 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'categories')]
private ?User $user = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
}

View file

@ -4,7 +4,9 @@ namespace App\Entity;
use App\Repository\ExpenseRepository;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: ExpenseRepository::class)]
class Expense
{

View file

@ -1,96 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\FestvialRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: FestvialRepository::class)]
class Festvial
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateCreation = null;
#[ORM\Column(nullable: true)]
private ?float $chiffreAffaire = null;
#[ORM\Column(nullable: true)]
private ?int $clientsCount = null;
#[ORM\Column(length: 500, nullable: true)]
private ?string $commentaire = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getDateCreation(): ?\DateTimeInterface
{
return $this->dateCreation;
}
public function setDateCreation(?\DateTimeInterface $dateCreation): static
{
$this->dateCreation = $dateCreation;
return $this;
}
public function getChiffreAffaire(): ?float
{
return $this->chiffreAffaire;
}
public function setChiffreAffaire(?float $chiffreAffaire): static
{
$this->chiffreAffaire = $chiffreAffaire;
return $this;
}
public function getClientsCount(): ?int
{
return $this->clientsCount;
}
public function setClientsCount(?int $clientsCount): static
{
$this->clientsCount = $clientsCount;
return $this;
}
public function getCommentaire(): ?string
{
return $this->commentaire;
}
public function setCommentaire(?string $commentaire): static
{
$this->commentaire = $commentaire;
return $this;
}
}

View file

@ -7,7 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: GroupOfProductsRepository::class)]
class GroupOfProducts
{

View file

@ -2,11 +2,13 @@
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: ProductRepository::class)]
class Product
{

View file

@ -7,7 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: SellingRepository::class)]
class Selling
{

View file

@ -7,7 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: SerieFestivalRepository::class)]
class SerieFestival
{

View file

@ -10,7 +10,9 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
@ -75,12 +77,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\OneToMany(targetEntity: Festival::class, mappedBy: 'user')]
private Collection $festivals;
/**
* @var Collection<int, Category>
*/
#[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'user')]
private Collection $categories;
/**
* @var Collection<int, SerieFestival>
*/
@ -94,7 +90,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
$this->products = new ArrayCollection();
$this->groupOfProducts = new ArrayCollection();
$this->festivals = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->seriesFestival = new ArrayCollection();
}
@ -173,18 +168,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
// $this->plainPassword = null;
}
public function getOwner(): ?object
{
return $this->owner;
}
public function setOwner(object $owner): static
{
$this->owner = $owner;
return $this;
}
public function getExpenses(): ?object
{
return $this->expenses;
@ -333,35 +316,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
/**
* @return Collection<int, Category>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): static
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
$category->setUser($this);
}
return $this;
}
public function removeCategory(Category $category): static
{
if ($this->categories->removeElement($category)) {
// set the owning side to null (unless already changed)
if ($category->getUser() === $this) {
$category->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, SerieFestival>