feat: add update status endpoint
This commit is contained in:
@@ -30,7 +30,8 @@ class Task
|
||||
|
||||
private string $start;
|
||||
|
||||
private string $startDt;
|
||||
|
||||
private array $dirty = [];
|
||||
|
||||
|
||||
public function __construct($status = TaskStatus::STARTED)
|
||||
@@ -40,6 +41,19 @@ class Task
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function markDirty($field): bool
|
||||
{
|
||||
if(property_exists(self::class, $field))
|
||||
{
|
||||
$this->dirty[] = $field;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getTaskOwner(): int
|
||||
{
|
||||
return self::task_owner;
|
||||
@@ -55,6 +69,16 @@ class Task
|
||||
$this->updatedAt = Carbon::now();
|
||||
}
|
||||
|
||||
public function getCreatedAt(): string
|
||||
{
|
||||
return $this->createdAt->toDateTimeString();
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): string
|
||||
{
|
||||
return $this->updatedAt->toDateTimeString();
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
@@ -63,6 +87,7 @@ class Task
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->touch();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -74,6 +99,7 @@ class Task
|
||||
public function setDescription(string $description): self
|
||||
{
|
||||
$this->description = $description;
|
||||
$this->touch();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -85,6 +111,7 @@ class Task
|
||||
public function setStart(string $start): self
|
||||
{
|
||||
$this->start = Carbon::parse($start)->toDateTimeString();
|
||||
$this->touch();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -96,6 +123,7 @@ class Task
|
||||
public function setEnd(string $end): self
|
||||
{
|
||||
$this->end = Carbon::parse($end)->toDateTimeString();
|
||||
$this->touch();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -107,6 +135,7 @@ class Task
|
||||
public function setStatusId(TaskStatus $statusId): self
|
||||
{
|
||||
$this->statusId = $statusId;
|
||||
$this->touch();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -119,6 +148,7 @@ class Task
|
||||
public function setId(int $id): Task
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->touch();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -148,8 +178,8 @@ class Task
|
||||
return [
|
||||
'id' => $this->id ?? null,
|
||||
'task_owner' => 1, // fake hard-coded user for now
|
||||
'created_at' => $this->createdAt->toDateTimeString(),
|
||||
'updated_at' => $this->updatedAt->toDateTimeString(),
|
||||
'created_at' => $this->getCreatedAt(),
|
||||
'updated_at' => $this->getUpdatedAt(),
|
||||
'name' => $this->getName(),
|
||||
'description' => $this->getDescription(),
|
||||
'start' => $this->getStart(),
|
||||
|
Reference in New Issue
Block a user