<?php
namespace App\Containers\SettingSection\PartnerContainer\Entities;
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 ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Containers\SettingSection\PartnerContainer\Data\Repositories\PartnerRepository;
use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
/**
* Партнери
*/
#[ApiResource(
routePrefix: '/list',
normalizationContext: ['groups' => ['read']],
operations: [
new Get(
uriTemplate: '/partner/{id}', requirements: ['id' => '\d+'],
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
),
new Patch(
uriTemplate: '/partner/{id}', requirements: ['id' => '\d+'],
security: "is_granted('ROLE_ADMIN')"
),
new Delete(
uriTemplate: '/partner/{id}', requirements: ['id' => '\d+'],
security: "is_granted('ROLE_ADMIN')"
),
new Post(
uriTemplate: '/partner',
security: "is_granted('ROLE_ADMIN')"
),
new GetCollection(
uriTemplate: '/partner',
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
),
],
shortName: 'List_Partner'
)]
#[ApiFilter(SearchFilter::class, properties: [
'id' => 'exact',
'name' => 'partial',
'code' => 'partial',
])]
#[ApiFilter(NumericFilter::class, properties: ['id'])]
#[ApiFilter(RangeFilter::class, properties: ['id'])]
#[ApiFilter(OrderFilter::class)]
#[ApiFilter(filterClass: SimpleSearchFilter::class, properties: [
'name', 'code'
])]
#[ORM\Entity(repositoryClass: PartnerRepository::class)]
#[ORM\Table(name: '`list_partner`')]
class PartnerEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
#[Groups(['read'])]
private ?int $id = null;
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
#[Groups(['read'])]
private string $name;
#[ORM\Column(type: Types::STRING, length: 255, nullable: false, unique: true)]
#[Groups(['read'])]
private string $code;
#[ORM\Column(type: Types::INTEGER, length: 10, nullable: true)]
#[Groups(['read'])]
private ?int $bonuses;
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected $createdAt;
#[Gedmo\Timestampable(on: 'update')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getCode()
{
return $this->code;
}
public function setCode($code)
{
$this->code = $code;
return $this;
}
public function getBonuses(): ?int
{
return $this->bonuses;
}
public function setBonuses(?int $bonuses): ?self
{
$this->bonuses = $bonuses;
return $this;
}
}