src/Entity/Projects.php line 46
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Delete;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Patch;use ApiPlatform\Metadata\Post;use App\Controller\ProjectsController;use App\Controller\MediaGetController;use App\Controller\ProjectsGetController;use App\Entity\Traits\CreatedAtTrait;use App\Entity\Traits\UpdatedAtTrait;use App\Repository\ProjectsRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\HasLifecycleCallbacks]#[ORM\Entity(repositoryClass: ProjectsRepository::class)]#[ApiResource(operations: [new GetCollection(uriTemplate: '/user/projects',controller: ProjectsController::class,normalizationContext: ['groups' => ['projects:read']],security: "is_granted('ROLE_USER')",),new Patch(denormalizationContext: ['groups' => ['projects:update']]),new Get(uriTemplate: '/user/projects/{id}',controller: ProjectsGetController::class,normalizationContext: ['groups' => ['projects:read']],security: "is_granted('ROLE_USER')",)],normalizationContext: ['groups' => ['projects:read']],paginationEnabled: false)]class Projects{use CreatedAtTrait;use UpdatedAtTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['projects:read'])]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['projects:write', 'projects:update', 'projects:read'])]private ?string $title = null;#[ORM\Column]#[Groups(['projects:write', 'projects:read', 'projects:update'])]private ?int $width = null;#[ORM\Column]#[Groups(['projects:write', 'projects:read', 'projects:update'])]private ?int $height = null;#[ORM\Column(length: 255)]#[Groups(['projects:write', 'projects:read', 'projects:update'])]private ?string $orientation = null;#[ORM\Column]#[Groups(['projects:write', 'projects:read', 'projects:update'])]private array $widgets = [];#[ORM\OneToMany(mappedBy: 'project', targetEntity: Pages::class, cascade: ['all'])]#[Groups(['projects:read'])]private Collection $pages;#[ORM\ManyToOne(cascade: ['all'], inversedBy: 'projects')]#[ORM\JoinColumn(nullable: false)]private ?Client $client = null;public function __construct(){$this->pages = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getTitle(): ?string{return $this->title;}public function setTitle(string $title): static{$this->title = $title;return $this;}public function getWidth(): ?int{return $this->width;}public function setWidth(int $width): static{$this->width = $width;return $this;}public function getHeight(): ?int{return $this->height;}public function setHeight(int $height): static{$this->height = $height;return $this;}public function getOrientation(): ?string{return $this->orientation;}public function setOrientation(string $orientation): static{$this->orientation = $orientation;return $this;}public function getWidgets(): array{return $this->widgets;}public function setWidgets(array $widgets): static{$this->widgets = $widgets;return $this;}/*** @return Collection<int, Pages>*/public function getPages(): Collection{return $this->pages;}public function addPage(Pages $page): static{if (!$this->pages->contains($page)) {$this->pages->add($page);$page->setProject($this);}return $this;}public function removePage(Pages $page): static{if ($this->pages->removeElement($page)) {// set the owning side to null (unless already changed)if ($page->getProject() === $this) {$page->setProject(null);}}return $this;}public function getClient(): ?Client{return $this->client;}public function setClient(?Client $client): static{$this->client = $client;return $this;}}