- Add OpenSpec experimental workflow with commands (opsx-apply, opsx-archive, opsx-explore, opsx-propose) - Add Serena memory system for project context - Implement User API (UserController, UserModel, routes) - Add Specimen delete endpoint - Update Test definitions and Routes - Sync API documentation (OpenAPI) - Archive completed 2026-03-08-backend-specs change
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
// ============================================================================
|
|
// ADD THIS METHOD TO: app/Controllers/Specimen/SpecimenController.php
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Delete a specimen (soft delete)
|
|
* DELETE /api/specimen/(:num)
|
|
*/
|
|
public function delete($id) {
|
|
try {
|
|
// Check if specimen exists
|
|
$specimen = $this->model->where('SID', $id)->first();
|
|
|
|
if (empty($specimen)) {
|
|
return $this->respond([
|
|
'status' => 'failed',
|
|
'message' => 'Specimen not found',
|
|
'data' => null
|
|
], 404);
|
|
}
|
|
|
|
// Perform soft delete (set DelDate)
|
|
$deleted = $this->model->update($id, [
|
|
'DelDate' => date('Y-m-d H:i:s')
|
|
]);
|
|
|
|
if (!$deleted) {
|
|
return $this->respond([
|
|
'status' => 'failed',
|
|
'message' => 'Failed to delete specimen',
|
|
'data' => null
|
|
], 500);
|
|
}
|
|
|
|
return $this->respond([
|
|
'status' => 'success',
|
|
'message' => 'Specimen deleted successfully',
|
|
'data' => ['SID' => $id]
|
|
], 200);
|
|
|
|
} catch (\Exception $e) {
|
|
log_message('error', 'SpecimenController::delete error: ' . $e->getMessage());
|
|
return $this->respond([
|
|
'status' => 'failed',
|
|
'message' => 'Failed to delete specimen',
|
|
'data' => null
|
|
], 500);
|
|
}
|
|
}
|