Endpoint
Description
Deletes a specific article by ID, including all associated images. The article is soft-deleted, meaning it’s marked as deleted but remains in the database for potential recovery. The endpoint:- Validates that the article exists
- Deletes all associated images from storage and database
- Soft-deletes the article record
- Uses database transactions to ensure atomicity
This endpoint performs a soft delete. The article is marked as deleted but can be recovered by database administrators if needed. All image files are permanently deleted from storage.
Authentication
Bearer token for authentication. Format:
Bearer YOUR_JWT_TOKENUser must have the Admin role. Regular users will receive a 403 Forbidden response.
Headers
Language preference for response messages. Supported values:
en, esResponse content type
Path Parameters
The unique ID of the article to delete
Response
Success Response (200 OK)
Always
true for successful deletionsSuccess message indicating the article was deleted
No data is returned for delete operations
Example Request
Example Response
Success (200 OK)
Error Responses
401 - Unauthorized
Returned when no authentication token is provided or the token is invalid.403 - Forbidden (Not Admin)
Returned when the authenticated user doesn’t have the Admin role.400 - Bad Request (Article Not Found)
Returned when trying to delete an article that doesn’t exist or has already been deleted.500 - Internal Server Error
Returned when the deletion fails due to a server error (e.g., database transaction failure, file system error).Deletion Process
The deletion follows this sequence:- Validation: Check if the article exists
- Transaction Start: Begin database transaction
- Image Deletion:
- Delete all image files from storage
- Remove all image records from database
- Article Deletion: Soft-delete the article record
- Transaction Commit: Commit if all steps succeed
- Rollback: If any step fails, all changes are rolled back
Implementation Notes
- Uses the
SoftDeletestrait - articles are not permanently removed from the database - The
deleted_attimestamp is set when the article is deleted - All associated images are permanently deleted from file storage
- All image database records are permanently deleted
- Uses database transactions to ensure atomicity (all or nothing)
- Laravel’s route model binding handles non-existent IDs
- If any part of the deletion fails, the entire operation is rolled back
Recovery
Since this is a soft delete, database administrators can recover deleted articles by updating thedeleted_at column:
Image files cannot be recovered after deletion. Only the article metadata can be restored.
Source Code Reference:
ArticleController::destroy() at /home/daytona/workspace/source/app/Http/Controllers/ArticleController.php:297