/** * Deletes a time record * * @apiMethod DELETE * @apiUri /api/time/records/{id} * @apiParameter { * "name": "id", * "description": "Record id", * "type": "integer", * "required": true, * "default": null * } * @return void */ public function deleteTask() { // Require authentication and authorization $this->requiresAuthentication(); $this->authorizeOrFail(); // Create object and store content $record = Record::oneOrFail(Request::getInt('id')); if (!$record->isMine()) { App::abort(401, 'Unauthorized'); } // Do the actual save if (!$record->destroy()) { App::abort(500, 'Record deletion failed'); } // Return message $this->send('Record successfully deleted', 200); }
/** * Delete records * * @return void */ public function deleteTask() { $record = Record::oneOrFail(Request::getInt('id')); // Only allow creator of the record to edit or delete if (!$record->isMine()) { // Set the redirect App::redirect(Route::url($this->base), Lang::txt('COM_TIME_RECORDS_WARNING_CANT_DELETE_OTHER'), 'warning'); return; } // Delete record $record->destroy(); // Set the redirect App::redirect(Route::url($this->base . $this->start($record)), Lang::txt('COM_TIME_RECORDS_DELETE_SUCCESSFUL'), 'passed'); }