fix: add missing task logic to task repo
This commit is contained in:
parent
b48fd48f24
commit
c0871bf214
@ -4,6 +4,7 @@ namespace Repositories;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Database\Connection;
|
||||
use Exceptions\TaskNotFoundException;
|
||||
use Interfaces\TaskDao;
|
||||
use Models\Task;
|
||||
use PDO;
|
||||
@ -48,12 +49,20 @@ class TaskRepository implements TaskDao
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TaskNotFoundException
|
||||
*/
|
||||
public function readById($id): Task
|
||||
{
|
||||
$stmt = $this->conn->prepare('SELECT * FROM Tasks WHERE id = ?');
|
||||
$stmt->execute([$id]);
|
||||
|
||||
return Task::fromArray($stmt->fetch(PDO::FETCH_ASSOC));
|
||||
if (!$data = $stmt->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
throw new TaskNotFoundException('Task not found.');
|
||||
}
|
||||
|
||||
return Task::fromArray($data);
|
||||
}
|
||||
|
||||
public function update(Task $task): bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user