**刪除記錄**
使用Model刪除記錄,成功則提示刪除成功,失敗則提示刪除失敗。
* 定義
~~~
/**
* 刪除記錄
*
* @param mixed $model
* @param string $isSoft
* @param string $url
* @return void
*/
protected function _delete($model, $isSoft = false, $url = null)
{
$map = [
'id' => $this->_id()
];
$model = $this->buildModel($model);
$url || $url = self::JUMP_REFRESH;
$status = $isSoft ? $model->softDelete($map) : $model->where($map)->delete();
if ($status) {
$this->success('刪除成功', $url);
} else {
$this->error('刪除失敗');
}
}
~~~
* 使用
~~~
$this->_delete(ConfigModel::class, false, self::JUMP_REFRESH);
~~~