salines / cakephp4-soft-delete Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Please, update your library on line 60 of the file SoftDeleteTrait.php.
Change the line with:
$primaryKey = (array)$this->primaryKey();
with
$primaryKey = (array)$this->getPrimaryKey();
Regards
Thanks for this nice library!
It would be awesome to be able to return only the deleted records. For this a new custom-finder could be implemented.
Something like:
$user = $this->Users->find('all', ['onlyDeleted']);
Implementation could be:
public function triggerBeforeFind(): void
{
if (!$this->_beforeFindFired && $this->_type === 'select') {
parent::triggerBeforeFind();
$aliasedField = $this
->getRepository()
->aliasField($this->getRepository()->getSoftDeleteField());
if (!is_array($this->getOptions()) || !in_array('withDeleted', $this->getOptions())) {
$this->andWhere($aliasedField . ' IS NULL');
}
if (!is_array($this->getOptions()) || !in_array('onlyDeleted', $this->getOptions())) {
$this->andWhere($aliasedField . ' IS NOT NULL');
}
}
}
Best regards,
Patrick
In my project the soft-delete plugin stopped working with the update to cakephp 4.5.
The triggerBeforeFind Method is only executed with update queries and not select queries. Therefore the "deleted IS NULL" clause is not appended to the where-statement. I suspect it goes back to this change in 4.5: https://book.cakephp.org/4/en/appendices/4-5-migration-guide.html#orm-query-api-deprecations
hardDelete return "Unknown method "primaryKey" called on ..."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.