Add task toggle and delete

This commit is contained in:
Dane Everitt 2016-09-05 17:13:22 -04:00
parent 91ad9b3eaa
commit 9b4a0ed143
4 changed files with 174 additions and 2 deletions

View file

@ -53,6 +53,43 @@ class TaskRepository
//
}
/**
* Deletes a given task.
* @param int $id
*
* @return bool
*/
public function delete($id)
{
$task = Models\Task::findOrFail($id);
try {
$task->delete();
return true;
} catch (\Exception $ex) {
throw $ex;
}
}
/**
* Toggles a task active or inactive.
* @param int $id
*
* @return int
*/
public function toggle($id)
{
$task = Models\Task::findOrFail($id);
try {
$task->active = ($task->active === 1) ? 0 : 1;
$task->queued = 0;
$task->save();
return $task->active;
} catch (\Exception $ex) {
throw $ex;
}
}
/**
* Create a new scheduled task for a given server.
* @param int $id