Question:
I would like to know if there is any way to use soft delete but check if there are relationships/data/records linked to the record that will be deleted before deleting.
This is clear, using only Laravel itself.
So, how to check relationships automatically before performing soft delete?
Answer:
I already needed this in a project and what I did was perform a search before performing the soft-delete. In my case, it was ok because only 2 tables were related to the one that was being manipulated.
To work with a context where you can have related n-tables, and sometimes tables of plugins or modules that may or may not be active, you can create a class derived from the idea of the observable pattern.
Create this class with an array of models that must be consulted when the soft-delete is to be executed. Each model must be inserted in this class when instantiated/read.
One way for the model to be inserted, in Laravel, is to create a register and perform the insertion at the time of registration.
Sorry not to pass example code as I won't be able to do this at the moment, I hope the idea helps as Laravel doesn't have this by default.