Hello, This is my first time using twill and I liked it.
It seems that I can disable soft deletes in createDefaultTableFields helper function:

But when I open the module page in admin panel I got this error:
Column not found: 1054 Unknown column 'deleted_at' in 'where clause' (SQL: select count(*) as aggregate from `pages` where exists (select * from `page_translations` where `pages`.`id` = `page_translations`.`page_id` and `page_translations`.`deleted_at` is null) and `deleted_at` is not null)
How can I disable soft deletes completly?
It seems that SoftDeletes trait is used in the twill model. So I can't remove it from my Page model without removing extends.
EDIT: Maybe I can create a new model class that doesn't use SoftDeletes trait. But I don't know if there is a built-in feature in twill to disable soft deletes without rewriting the model.
I was looking in source for solutions to this. Extending and omitting SoftDeletes from \App\Twill\Models\Model and setting $softDeletes = false in a migration results in further issues so extending will not solve this unfortunately. Short discission related to this can be found at https://spectrum.chat/twill/feature-requests/ability-to-remove-soft-deleted-cms-users~03ebf9b4-7215-4aa0-a4c0-f935e19436c3
Hi @ammardev @titantwentyone, I was hoping that using $softDeletes = false would make this possible but have to admit we haven't tested that use case. We should definitely provide an option to disable it.
Perhaps a future version of Twill could have a "Delete" option next to "Restore" as an action on items that are in the Trash. It wouldn't require any database changes and could live as a new method on the ModuleRepository that utilizes force delete: $model->forceDelete().
Just another thought but one idea would be to create a trait of hasSoftDeletes which can be added to a model and to take it out of Twill\Models\Model.
trait hasSoftDeletes
{
use SoftDeletes;
}
This could be applied by default on new models (possibly adding a switch to php artisan twill:module to disable if needed). Ths isn't a fix per se as we still need to look at what other code requires the use of SoftDeletes but a way to start thinking about refactoring if needed.
@titantwentyone Do you mean something like this:
php artisan twill:module pages --hasSoftDelete
@ammardev I think softDeletes should be enabled by default as they are the norm. So a switch which does the opposite is probably preferable:
php artisan twill:module pages --removeSoftDelete
Destroying from the trash is now possible. Let us know if disabling soft deletes is still an issue for you.
Most helpful comment
@ammardev I think softDeletes should be enabled by default as they are the norm. So a switch which does the opposite is probably preferable: