更新 app/Admin/Services/KeywordService.php
parent
57506111ba
commit
b84018eb00
|
|
@ -31,14 +31,22 @@ class KeywordService extends BaseService
|
|||
return ['items' => $this->getTree(request()->all())];
|
||||
}
|
||||
|
||||
public function delete(string $ids): mixed
|
||||
/**
|
||||
* 删除的前置方法
|
||||
*
|
||||
* @param array $ids 主键id
|
||||
* @return mixed true: 继续后续操作, string: 中断操作, 返回错误提示
|
||||
*/
|
||||
public function preDelete(array $ids)
|
||||
{
|
||||
$ids = explode(',', $ids);
|
||||
if (count($ids) == 1) {
|
||||
$this->query()->where('path', 'like', '%-'.$ids[0].'-%')->delete();
|
||||
}
|
||||
// 删除子级
|
||||
$this->query()->where(function ($q) use ($ids) {
|
||||
foreach ($ids as $id) {
|
||||
$q->orWhere('path', 'like', '%-'.$id.'-%');
|
||||
}
|
||||
})->delete();
|
||||
|
||||
return $this->query()->whereIn('id', $ids)->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate($data, $id = null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue