PHP code example of madulinux / repository-pattern
1. Go to this page and download the library: Download madulinux/repository-pattern library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$repository->on('creating', function($data) {
// Before create
});
$repository->on('created', function($model) {
// After create
});
// Available events:
// - creating/created
// - updating/updated
// - deleting/deleted
// Get with soft deleted records
$repository->withTrashed()->get();
// Get only soft deleted records
$repository->onlyTrashed()->get();
// Restore soft deleted records
$repository->restore($id);
// Force delete
$repository->forceDelete($id);