I’m a bit confused with the SoftDelete trait right now:
I use it plenty of times in my models, so basically this works for me.
However on one model, It shows me the message: “Error - Access denied”. Since I am the main admin it should not be a permission issue. Here’s the button:
If I use the trash-button inside the model form, the deletion works. Also there’s the deleted_at column as well as the SoftDelete Trait included. Else the delete in the model wouldnt work anyways.
Hm, I might miss something: How to I activate this in the list config? I checked all my other list configs where I use delete and… I couldnt find anything there? Yes I use the SoftDelete trait in the models, but… is there another option that I missed?
Ok I’m not sure how I could overlook this so far, but I had two list configurations for this area.
The FULL listConfig has the showCheckboxes: true, the VIEW listConfig does not.
If I add the showCheckboxes to the VIEW config, the onDelete handler just works.
If not, the handler does not work properly.
Also my listRefresh() didnt work in some handlers since I had to do a listRefresh(“FULL”) instead.
So now I wonder:
Is it a bug, that if there’re two list configs and only one has the checkboxes active, the onDelete handler does not work?
Also onDelete does not refresh the list which since the handler does not know which list config to reload, but this seems reasonable ofc.
What would be the “best practice” to solve this?
As a workaround, I overwrote the onDelete handler like this:
public function onDelete()
{
if (!BackendUserHelper::checkPermission($this->user, 'mch.heads.valrules.full')) return;
$checkedIds = HandlerHelper::getCheckedIds();
if (empty($checkedIds)) return;
ValidationRule::whereIn('id', $checkedIds)->delete();
Flash::success(e(trans('backend::lang.list.delete_selected')));
return $this->listRefresh("full");
}