I can't figure out how to delete properly an uploaded file.
In my model:
...
public $attachMany = [
'attestations' => ['System\Models\File', 'order' => 'created_at desc', 'delete' => true]
];
...
In my controller:
...
public function update_onDeleteFile($recordId = null)
{
$data = post();
$member = Member::find($recordId);
$member->attestations()->where('id', $data['file_id'])->delete();
}
...
The model seems being deleted correctly (ie: the row no longer exists in the system_files table).
But the physical file is still there in the storage directory.
storage/app/uploads/public/5ff/56e/945/5ff56e9452a45600617548.pdf
How can I remove the model and the file at once ?