feat : wip

This commit is contained in:
2026-02-16 14:43:37 +01:00
parent 2a9b047913
commit 1cfbfb0120
8 changed files with 845 additions and 0 deletions

178
src/Entity/WorkHour.php Normal file
View File

@@ -0,0 +1,178 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ApiResource(
operations: [
new GetCollection(
paginationEnabled: false,
normalizationContext: ['groups' => ['work_hour:read', 'employee:read', 'site:read']],
security: "is_granted('ROLE_USER')"
),
new Get(
normalizationContext: ['groups' => ['work_hour:read', 'employee:read', 'site:read']],
security: "is_granted('WORK_HOUR_VIEW', object)"
),
],
)]
#[ApiFilter(DateFilter::class, properties: ['workDate'])]
#[ApiFilter(SearchFilter::class, properties: ['employee' => 'exact', 'employee.site' => 'exact'])]
#[ORM\Entity]
#[ORM\Table(name: 'work_hours')]
#[ORM\UniqueConstraint(name: 'uniq_work_hours_employee_date', fields: ['employee', 'workDate'])]
class WorkHour
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['work_hour:read'])]
private ?int $id = null;
#[ApiProperty(readableLink: true)]
#[ORM\ManyToOne(targetEntity: Employee::class)]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['work_hour:read'])]
private ?Employee $employee = null;
#[ORM\Column(type: 'date_immutable')]
#[Groups(['work_hour:read'])]
private DateTimeInterface $workDate;
#[ORM\Column(type: 'string', length: 5, nullable: true)]
#[Groups(['work_hour:read'])]
private ?string $morningFrom = null;
#[ORM\Column(type: 'string', length: 5, nullable: true)]
#[Groups(['work_hour:read'])]
private ?string $morningTo = null;
#[ORM\Column(type: 'string', length: 5, nullable: true)]
#[Groups(['work_hour:read'])]
private ?string $afternoonFrom = null;
#[ORM\Column(type: 'string', length: 5, nullable: true)]
#[Groups(['work_hour:read'])]
private ?string $afternoonTo = null;
#[ORM\Column(type: 'string', length: 5, nullable: true)]
#[Groups(['work_hour:read'])]
private ?string $eveningFrom = null;
#[ORM\Column(type: 'string', length: 5, nullable: true)]
#[Groups(['work_hour:read'])]
private ?string $eveningTo = null;
public function getId(): ?int
{
return $this->id;
}
public function getEmployee(): ?Employee
{
return $this->employee;
}
public function setEmployee(?Employee $employee): self
{
$this->employee = $employee;
return $this;
}
public function getWorkDate(): DateTimeInterface
{
return $this->workDate;
}
public function setWorkDate(DateTimeInterface $workDate): self
{
$this->workDate = $workDate;
return $this;
}
public function getMorningFrom(): ?string
{
return $this->morningFrom;
}
public function setMorningFrom(?string $morningFrom): self
{
$this->morningFrom = $morningFrom;
return $this;
}
public function getMorningTo(): ?string
{
return $this->morningTo;
}
public function setMorningTo(?string $morningTo): self
{
$this->morningTo = $morningTo;
return $this;
}
public function getAfternoonFrom(): ?string
{
return $this->afternoonFrom;
}
public function setAfternoonFrom(?string $afternoonFrom): self
{
$this->afternoonFrom = $afternoonFrom;
return $this;
}
public function getAfternoonTo(): ?string
{
return $this->afternoonTo;
}
public function setAfternoonTo(?string $afternoonTo): self
{
$this->afternoonTo = $afternoonTo;
return $this;
}
public function getEveningFrom(): ?string
{
return $this->eveningFrom;
}
public function setEveningFrom(?string $eveningFrom): self
{
$this->eveningFrom = $eveningFrom;
return $this;
}
public function getEveningTo(): ?string
{
return $this->eveningTo;
}
public function setEveningTo(?string $eveningTo): self
{
$this->eveningTo = $eveningTo;
return $this;
}
}