/**
  * Remove task
  * @param  \Todo\Model\Task $task
  * @return boolean
  */
 public function removeTask($task)
 {
     $query = 'DELETE FROM tasks WHERE id=:id';
     $id = $task->getId();
     $stmt = $this->conn->prepare($query);
     $stmt->bindParam('id', $id);
     return $stmt->execute();
 }
Example #2
0
// ini_set('display_errors', 1);
// error_reporting(-1);
// Something for angular to make CORS PUT requests pass
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    header("HTTP/1.1 200 OK");
    exit;
}
require '../vendor/autoload.php';
// Create Slim...
$app = new \Slim\Slim();
// ... and enable JSON API views
$app->view(new \JsonApiView());
$app->add(new \JsonApiMiddleware());
// Set up database connection and repository
$config = (require '../app/config.php');
$db = new Todo\Db\PDO($config['db']);
$conn = $db->connect();
$repository = new Todo\Repository\TaskRepository($conn);
/**
 * Task resource
 *
 * GET /task - get all tasks
 * GET /task/:id - get task
 * POST /task/:id - update task
 * PUT /task - create new task
 * DELETE /task/:id - remove task
 */
/**
 * Get list of all tasks
 */
$app->get('/task', function () use($app, $repository) {