🎨 改进结构
This commit is contained in:
@@ -31,7 +31,7 @@ class AlbumController extends Controller
|
||||
if ($user->albums()->create(array_filter($request->validated()))) {
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
return $this->error('创建失败');
|
||||
return $this->fail('创建失败');
|
||||
}
|
||||
|
||||
public function update(AlbumRequest $request): Response
|
||||
@@ -40,7 +40,7 @@ class AlbumController extends Controller
|
||||
$user = Auth::user();
|
||||
$album = $user->albums()->find($request->route('id'));
|
||||
if (is_null($album)) {
|
||||
return $this->error('不存在的相册');
|
||||
return $this->fail('不存在的相册');
|
||||
}
|
||||
$album->update(array_filter($request->validated()));
|
||||
return $this->success('修改成功');
|
||||
@@ -53,7 +53,7 @@ class AlbumController extends Controller
|
||||
/** @var Album|null $album */
|
||||
$album = $user->albums()->find($request->route('id'));
|
||||
if (is_null($album)) {
|
||||
return $this->error('不存在的相册');
|
||||
return $this->fail('不存在的相册');
|
||||
}
|
||||
DB::transaction(function () use ($album) {
|
||||
$album->images()->update(['album_id' => null]);
|
||||
|
||||
@@ -44,7 +44,7 @@ class ImageController extends Controller
|
||||
$user = Auth::user();
|
||||
/** @var Image $image */
|
||||
if (!$image = $user->images()->find($request->route('id'))) {
|
||||
return $this->error('未找到该图片');
|
||||
return $this->fail('未找到该图片');
|
||||
}
|
||||
$image->strategy->setVisible(['name']);
|
||||
$image->album?->setVisible(['name']);
|
||||
@@ -62,7 +62,7 @@ class ImageController extends Controller
|
||||
$permission = $request->input('permission');
|
||||
$permissions = ['public' => ImagePermission::Public, 'private' => ImagePermission::Private];
|
||||
if (!in_array($permission, array_keys($permissions))) {
|
||||
return $this->error('设置失败');
|
||||
return $this->fail('设置失败');
|
||||
}
|
||||
$user->images()->whereIn('id', (array) $request->input('ids'))->update([
|
||||
'permission' => $permissions[$permission],
|
||||
|
||||
@@ -56,7 +56,7 @@ class UserController extends Controller
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
if (! $strategy = $user->group->strategies()->find($request->id)) {
|
||||
return $this->error('没有找到该策略');
|
||||
return $this->fail('没有找到该策略');
|
||||
}
|
||||
$user->update(['configs->'.UserConfigKey::DefaultStrategy => $strategy->id]);
|
||||
return $this->success('设置成功');
|
||||
|
||||
Reference in New Issue
Block a user