On this page
批量删除图片
控制器 app/controller/admin/Image.php
php
public function deleteAll()
{
$param = $this->request->param('ids');
// 找到所有数据
$data = $this->M->where('id','in',$param)->select();
$data->each(function($v){
// 删除当前数据
$v->delete();
});
return showSuccess(true);
}
验证器 app/validate/admin/Image.php
php
// 验证规则
protected $rule = [
...
'ids'=>'require|array'
...
];
protected $scene = [
...
'deleteAll'=>['ids']
];
路由 router/admin.php
php
Route::post('image/delete_all$','admin.Image/deleteAll');