1. Go to this page and download the library: Download fusic/reincarnation 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/ */
fusic / reincarnation example snippets
class UsersTable extends Table
{
public function initialize(array $config)
{
// Case 1
// default
// table field name
// boolean:deleted
// timestamp:delete_date
$this->addBehavior('Reincarnation.SoftDelete');
// Case 2
// field name custom
// table field name
// boolean:delete_flg
// timestamp:deleted
$this->addBehavior('Reincarnation.SoftDelete', ['boolean' => 'delete_flg', 'timestamp' => 'deleted']);
// Case 3
// boolean only
// table field name
// boolean:delete_flg
// timestamp:none
$this->addBehavior('Reincarnation.SoftDelete', ['boolean' => 'delete_flg', 'timestamp' => false]);
// Case 4
// timestamp only
// table field name
// boolean:none
// timestamp:deleted
$this->addBehavior('Reincarnation.SoftDelete', ['boolean' => false, 'timestamp' => 'deleted']);
}
}
class UsersController extends AppController
{
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$user = $this->Users->get($id);
if ($this->Users->softDelete($user)) {
//第二引数がtrueの場合、Entityのassociate先もあわせて削除します
//if ($this->Users->softDelete($user, true)) {
$this->Flash->success(__('The data has been deleted.'));
} else {
$this->Flash->error(__('The data could not be deleted. Please, try again.'));
}
return $this->redirect('action' => 'index');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.