...

/

Deleting Tours: Challenges of Soft-Deletion

Deleting Tours: Challenges of Soft-Deletion

Let's address some issues surrounding soft-delete.

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:

Press + to interact
<?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 ...

Access this course and 1400+ top-rated courses and projects.