PGBI/cakephp3-soft-delete

Soft deleted records should be fetched for belongsTo association queries.

mohsinrasool opened this issue · 2 comments

Hi,

I have been using your script for couple of my projects. Thanks for sharing it.

I have invoices that has a belongs to relation with clients model. When a client is soft deleted, all of its invoices shows empty clients array. Does this make sense that even if records is soft deleted, it should show up in belongs to relations? If so, how can that be implemented?

Thanks

@mohsinrasool You should be able to accomplish it like this:

'contain' => [
'Users' => function ($q) {
return $q->find('all', ['withDeleted']);
}
]