<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Controller\EthnicityController;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\EthnicityRepository")
* @ORM\HasLifecycleCallbacks()
*/
#[ApiResource(collectionOperations: [
'get', 'post',
'ethnicity_list' => [
'method' => 'GET',
'path' => '/ethnicity/list',
'controller' => EthnicityController::class,
],
], itemOperations: ['get', 'put'])]
#[ApiFilter(PropertyFilter::class)]
#[ApiFilter(SearchFilter::class, properties: ['id', 'name' => SearchFilter::STRATEGY_PARTIAL])]
#[ApiFilter(OrderFilter::class, properties: ['id', 'name'], arguments: ['orderParameterName' => 'order'])]
class Ethnicity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=128)
*/
private $name;
/**
* @var string
*
* @ORM\Column(type="text", nullable=true)
*/
private $detail;
public function __toString(): string
{
return $this->getName() . ((null !== $this->getDetail()) ? ' ' . $this->getDetail() : '');
}
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 getDetail(): ?string
{
return $this->detail;
}
public function setDetail(?string $detail): self
{
$this->detail = $detail;
return $this;
}
}