Deploy from Lumerel
This commit is contained in:
30
src/Models/Task.php
Normal file
30
src/Models/Task.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
require_once __DIR__ . '/../../db.php';
|
||||
|
||||
class Task {
|
||||
private $pdo;
|
||||
|
||||
public function __construct() {
|
||||
global $pdo;
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function create($name, $description, $projectId, $userId, $status = 'created') {
|
||||
$stmt = $this->pdo->prepare("INSERT INTO tasks (name, description, project_id, user_id, status) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $description, $projectId, $userId, $status]);
|
||||
return $this->pdo->lastInsertId();
|
||||
}
|
||||
|
||||
public function getProjectTasks($projectId) {
|
||||
$stmt = $this->pdo->prepare("SELECT * FROM tasks WHERE project_id = ? ORDER BY created_at DESC");
|
||||
$stmt->execute([$projectId]);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
public function updateTaskStatus($taskId, $status) {
|
||||
$stmt = $this->pdo->prepare("UPDATE tasks SET status = ? WHERE id = ?");
|
||||
return $stmt->execute([$status, $taskId]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user