src/Entity/AbsenceEmployee.php line 22
<?php
namespace App\Entity;
use DateTime;
use App\Entity\Company;
use App\Entity\Employee;
use Symfony\Component\Uid\Ulid;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\AbsenceEmployeeRepository;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Symfony\Component\Serializer\Annotation\Groups;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: AbsenceEmployeeRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[ORM\HasLifecycleCallbacks]
#[ApiResource(
attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
)]
class AbsenceEmployee
{
use Timestamps;
#[ORM\Id]
#[ORM\Column(type: 'ulid', unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Groups('read:absenceemployee:basic')]
private ?Ulid $id = null;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups('read:absenceemployee:basic')]
private $description;
#[ORM\Column(type: 'date')]
#[Groups('read:absenceemployee:basic')]
private $date;
#[ORM\Column(type: 'string', length: 255)]
#[Groups('read:absenceemployee:basic')]
private $duration = 'un jours';
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups('read:absenceemployee:basic')]
private $reason;
#[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'absenceEmployees')]
#[ORM\JoinColumn(nullable: false)]
private $employee;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'absenceEmployees')]
#[ORM\JoinColumn(nullable: false)]
private $owner;
#[ORM\ManyToOne(targetEntity: Season::class, inversedBy: 'absenceEmployees')]
#[ORM\JoinColumn(nullable: false)]
private $season;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'absenceEmployees')]
#[ORM\JoinColumn(nullable: false)]
private $created_by;
public function __construct()
{
return $this->name = ' ';
return $this->date = new DateTime();
}
public function getId(): ?Ulid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getDuration(): ?string
{
return $this->duration;
}
public function setDuration(string $duration): self
{
$this->duration = $duration;
return $this;
}
public function getReason(): ?string
{
return $this->reason;
}
public function setReason(?string $reason): self
{
$this->reason = $reason;
return $this;
}
public function getEmployee(): ?Employee
{
return $this->employee;
}
public function setEmployee(?Employee $employee): self
{
$this->employee = $employee;
return $this;
}
public function getOwner(): ?Company
{
return $this->owner;
}
public function setOwner(?Company $owner): self
{
$this->owner = $owner;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): self
{
$this->season = $season;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->created_by;
}
public function setCreatedBy(?User $created_by): self
{
$this->created_by = $created_by;
return $this;
}
}