<?php

namespace App\Entity;

use App\Repository\ProjectRepository;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\GetCollection;
use Symfony\Component\Serializer\Attribute\Groups;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ProjectRepository::class)]
#[ORM\Table(name: 'progetto')]
#[ApiResource(
    operations: [
        new Get(normalizationContext: ['groups' => 'project:item']),
        new GetCollection(normalizationContext: ['groups' => 'project:list']),
        new Post(security: "is_granted('ROLE_USER')"),
    ],
    order: ['name' => 'DESC'],
    paginationEnabled: false,
)]
class Project
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(type: Types::BIGINT, name: 'id_utente')]
    #[ORM\OneToOne(User::class, )]
    private ?string $userid = null;

    #[ORM\Column(type: Types::BIGINT, name: 'id_architettura')]
    private ?string $buildingid = null;

    #[ORM\Column(length: 255, nullable: true)]
    /**
     * @var string $ifc Path to IFC file for this project
     */
    private ?string $ifc = null;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function setId(string $id): static
    {
        $this->id = $id;

        return $this;
    }

    public function getUserid(): ?string
    {
        return $this->userid;
    }

    public function setUserid(string $userid): static
    {
        $this->userid = $userid;

        return $this;
    }

    public function getBuildingid(): ?string
    {
        return $this->buildingid;
    }

    public function setBuildingid(string $buildingid): static
    {
        $this->buildingid = $buildingid;

        return $this;
    }

    public function getIfc(): ?string
    {
        return $this->ifc;
    }

    public function setIfc(?string $ifc): static
    {
        $this->ifc = $ifc;

        return $this;
    }
}
