mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add id column on entity
This commit is contained in:
@@ -12,6 +12,9 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EntityRepository::class)]
|
||||
#[ORM\UniqueConstraint(
|
||||
columns: ['tld_id', 'handle']
|
||||
)]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
/*
|
||||
@@ -21,7 +24,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
),
|
||||
*/
|
||||
new Get(
|
||||
uriTemplate: '/entities/{handle}',
|
||||
uriTemplate: '/entities/{id}',
|
||||
normalizationContext: [
|
||||
'groups' => [
|
||||
'event:list',
|
||||
@@ -38,6 +41,15 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
class Entity
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: true)]
|
||||
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
||||
private ?Tld $tld = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
||||
private ?string $handle = null;
|
||||
@@ -205,4 +217,28 @@ class Entity
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(int $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTld(): ?Tld
|
||||
{
|
||||
return $this->tld;
|
||||
}
|
||||
|
||||
public function setTld(?Tld $tld): static
|
||||
{
|
||||
$this->tld = $tld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user