feat : ajout des sites pour les employés et retour arrière sur l'impression
This commit is contained in:
@@ -9,7 +9,10 @@ use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(normalizationContext: ['groups' => ['employee:read']])]
|
||||
#[ApiResource(
|
||||
normalizationContext: ['groups' => ['employee:read', 'site:read']],
|
||||
denormalizationContext: ['groups' => ['employee:write']]
|
||||
)]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'employees')]
|
||||
class Employee
|
||||
@@ -21,13 +24,19 @@ class Employee
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 100)]
|
||||
#[Groups(['absence:read', 'employee:read'])]
|
||||
#[Groups(['absence:read', 'employee:read', 'employee:write'])]
|
||||
private string $firstName = '';
|
||||
|
||||
#[ORM\Column(type: 'string', length: 100)]
|
||||
#[Groups(['absence:read', 'employee:read'])]
|
||||
#[Groups(['absence:read', 'employee:read', 'employee:write'])]
|
||||
private string $lastName = '';
|
||||
|
||||
#[ApiPlatform\Metadata\ApiProperty(readableLink: true)]
|
||||
#[ORM\ManyToOne(targetEntity: Site::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['employee:read', 'employee:write'])]
|
||||
private ?Site $site = null;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable')]
|
||||
private DateTimeImmutable $createdAt;
|
||||
|
||||
@@ -65,6 +74,18 @@ class Employee
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSite(): ?Site
|
||||
{
|
||||
return $this->site;
|
||||
}
|
||||
|
||||
public function setSite(?Site $site): self
|
||||
{
|
||||
$this->site = $site;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
|
||||
58
src/Entity/Site.php
Normal file
58
src/Entity/Site.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(normalizationContext: ['groups' => ['site:read']])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'sites')]
|
||||
class Site
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
#[Groups(['site:read', 'employee:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 150)]
|
||||
#[Groups(['site:read', 'employee:read'])]
|
||||
private string $name = '';
|
||||
|
||||
#[ORM\Column(type: 'string', length: 20)]
|
||||
#[Groups(['site:read', 'employee:read'])]
|
||||
private string $color = '';
|
||||
|
||||
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 getColor(): string
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function setColor(string $color): self
|
||||
{
|
||||
$this->color = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user