Search⌘ K
AI Features

Deleting Tours: Challenges of Soft-Deletion

Understand how to manage soft-deletion in PHP by filtering out deleted tours from display lists and merging submitted data with existing records to prevent deleted tours from unintentionally reappearing. Explore techniques to handle editing restrictions on deleted tours for better data consistency and application behavior.

The list of tours is never empty

There’s a slight issue. Try deleting all the tours. Eventually, we would expect to see the message “There are no tours (yet).” again. The code that produces this message is:

PHP
<?php
// ...
if (count($toursData) === 0) {
?><p>There are no tours (yet).</p><?php
}

When you think about it, $toursData is not empty; it just contains tours that have been deleted. So count($toursData) will never be 0 even when all the tours have been deleted.

Filtering out deleted tours

The solution is to filter out deleted tours before ...