修复删除策略或删除组导致500错误的bug
This commit is contained in:
@@ -59,8 +59,12 @@ class StrategyController extends Controller
|
||||
|
||||
public function delete(Request $request): Response
|
||||
{
|
||||
if ($group = Strategy::query()->find($request->route('id'))) {
|
||||
$group->delete();
|
||||
/** @var Strategy $strategy */
|
||||
if ($strategy = Strategy::query()->find($request->route('id'))) {
|
||||
DB::transaction(function () use ($strategy) {
|
||||
$strategy->images()->update(['strategy_id' => null]);
|
||||
$strategy->delete();
|
||||
});
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
@@ -169,10 +169,10 @@ class Image extends Model
|
||||
{
|
||||
return new Attribute(function () {
|
||||
// 是否启用原图保护功能
|
||||
if ($this->group->configs->get(GroupConfigKey::IsEnableOriginalProtection)) {
|
||||
if ($this->group?->configs->get(GroupConfigKey::IsEnableOriginalProtection)) {
|
||||
return asset("{$this->key}.{$this->extension}");
|
||||
} else {
|
||||
return rtrim($this->strategy->configs->get('url'), '/').'/'.$this->pathname;
|
||||
return rtrim($this->strategy?->configs->get('url'), '/').'/'.$this->pathname;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user