<?php

namespace App\Entity;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\MaterialRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;

#[ORM\Entity(repositoryClass: MaterialRepository::class)]
#[ORM\Table(name: 'voc_materiale')]
#[ApiResource(
    operations: [
        new Get(normalizationContext: ['groups' => 'material:item']),
        new GetCollection(normalizationContext: ['groups' => 'material:list'])
    ],
    order: ['term' => 'DESC'],
    paginationEnabled: false,
)]
class Material
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[Groups(['material:list', 'material:item'])]
    private ?int $id = null;

    #[ORM\Column(name: 'lemma', length: 50)]
    #[Groups(['material:list', 'material:item'])]
    private ?string $term = null;

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

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

        return $this;
    }

    public function getTerm(): ?string
    {
        return $this->term;
    }

    public function setTerm(string $term): static
    {
        $this->term = $term;

        return $this;
    }
}
