feat: add id setter for the Task model

This commit is contained in:
Miguel Nogueira 2025-04-13 22:17:37 +01:00
parent 0e44c78af6
commit 46c6dd6e58

View File

@ -88,7 +88,13 @@ class Task
}
public static function fromArray($taskData): Task
public function setId(int $id): Task
{
$this->id = $id;
return $this;
}
public static function fromArray($taskData): self
{
$task = new self();
@ -109,7 +115,8 @@ class Task
public function persist(): array
{
return [
'task_owner' => 1, // fake hard-coded user for now
'id' => $this->id ?? null,
'task_owner' => 1, // fake hard-coded user for now
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),
'name' => $this->getTitle(),
@ -117,7 +124,6 @@ class Task
'start' => $this->getStartDt(),
'end' => $this->getEndDt(),
'status_id' => $this->getStatus()->value
];
}