['time_entry:read']], denormalizationContext: ['groups' => ['time_entry:write']], order: ['startedAt' => 'DESC'], )] #[ApiFilter(SearchFilter::class, properties: ['user' => 'exact', 'project' => 'exact', 'types' => 'exact'])] #[ApiFilter(DateFilter::class, properties: ['startedAt'])] #[ORM\Entity(repositoryClass: TimeEntryRepository::class)] #[ORM\UniqueConstraint(name: 'uniq_active_timer', columns: ['user_id'], options: ['where' => '(stopped_at IS NULL)'])] class TimeEntry { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['time_entry:read'])] private ?int $id = null; #[ORM\Column(length: 255, nullable: true)] #[Groups(['time_entry:read', 'time_entry:write'])] private ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Groups(['time_entry:read', 'time_entry:write'])] private ?string $description = null; #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)] #[Groups(['time_entry:read', 'time_entry:write'])] private ?DateTimeImmutable $startedAt = null; #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)] #[Groups(['time_entry:read', 'time_entry:write'])] private ?DateTimeImmutable $stoppedAt = null; #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[Groups(['time_entry:read', 'time_entry:write'])] private ?User $user = null; #[ORM\ManyToOne(targetEntity: Project::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[Groups(['time_entry:read', 'time_entry:write'])] private ?Project $project = null; #[ORM\ManyToOne(targetEntity: Task::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] #[Groups(['time_entry:read', 'time_entry:write'])] private ?Task $task = null; /** @var Collection */ #[ORM\ManyToMany(targetEntity: TaskType::class)] #[ORM\JoinTable(name: 'time_entry_task_type')] #[Groups(['time_entry:read', 'time_entry:write'])] private Collection $types; public function __construct() { $this->types = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): static { $this->title = $title; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getStartedAt(): ?DateTimeImmutable { return $this->startedAt; } public function setStartedAt(DateTimeImmutable $startedAt): static { $this->startedAt = $startedAt; return $this; } public function getStoppedAt(): ?DateTimeImmutable { return $this->stoppedAt; } public function setStoppedAt(?DateTimeImmutable $stoppedAt): static { $this->stoppedAt = $stoppedAt; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): static { $this->user = $user; return $this; } public function getProject(): ?Project { return $this->project; } public function setProject(?Project $project): static { $this->project = $project; return $this; } public function getTask(): ?Task { return $this->task; } public function setTask(?Task $task): static { $this->task = $task; return $this; } /** @return Collection */ public function getTypes(): Collection { return $this->types; } public function addType(TaskType $type): static { if (!$this->types->contains($type)) { $this->types->add($type); } return $this; } public function removeType(TaskType $type): static { $this->types->removeElement($type); return $this; } }