更新 app/Admin/Services/KeywordService.php
parent
57506111ba
commit
b84018eb00
|
|
@ -31,14 +31,22 @@ class KeywordService extends BaseService
|
||||||
return ['items' => $this->getTree(request()->all())];
|
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(function ($q) use ($ids) {
|
||||||
$this->query()->where('path', 'like', '%-'.$ids[0].'-%')->delete();
|
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)
|
public function validate($data, $id = null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue