diff --git a/app/Http/Controllers/Admin/GroupController.php b/app/Http/Controllers/Admin/GroupController.php index 4007cb8f2..32b390ddf 100644 --- a/app/Http/Controllers/Admin/GroupController.php +++ b/app/Http/Controllers/Admin/GroupController.php @@ -28,10 +28,13 @@ private function share() public function index(Request $request): View { - $groups = Group::query()->when($request->query('keywords'), function (Builder $builder, $keywords) { + $keywords = $request->query('keywords'); + $groups = Group::query()->when($keywords, function (Builder $builder, $keywords) { $builder->where('name', 'like', "%{$keywords}%"); })->withCount('users')->withCount('strategies')->latest()->paginate(); + $groups->appends(compact('keywords')); + $this->share(); return view('admin.group.index', compact('groups')); diff --git a/app/Http/Controllers/Admin/ImageController.php b/app/Http/Controllers/Admin/ImageController.php index c6f39ac5f..6b32c077e 100644 --- a/app/Http/Controllers/Admin/ImageController.php +++ b/app/Http/Controllers/Admin/ImageController.php @@ -17,9 +17,10 @@ class ImageController extends Controller { public function index(Request $request): View { + $keywords = $request->query('keywords'); $images = Image::query()->with(['user' => function (BelongsTo $belongsTo) { $belongsTo->withSum('images', 'size'); - }, 'album', 'group', 'strategy'])->when($request->input('keywords'), function (Builder $builder, $keywords) { + }, 'album', 'group', 'strategy'])->when($keywords, function (Builder $builder, $keywords) { $words = []; $qualifiers = [ 'name:', 'album:', 'group:', 'strategy:', 'email:', 'extension:', 'md5:', 'sha1:', 'ip:', 'is:', 'order:', @@ -65,13 +66,14 @@ public function index(Request $request): View foreach ($words as $word) { $builder->where('origin_name', 'like', "%{$word}%")->orWhere('alias_name', 'like', "%{$word}%"); } - })->latest()->paginate(40); + })->latest()->paginate(1); $images->getCollection()->each(function (Image $image) { $image->append('url', 'pathname', 'thumb_url'); $image->album?->setVisible(['name']); $image->group?->setVisible(['name']); $image->strategy?->setVisible(['name']); }); + $images->appends(compact('keywords')); return view('admin.image.index', compact('images')); } diff --git a/app/Http/Controllers/Admin/StrategyController.php b/app/Http/Controllers/Admin/StrategyController.php index 8ea52e1f6..3d187c4be 100644 --- a/app/Http/Controllers/Admin/StrategyController.php +++ b/app/Http/Controllers/Admin/StrategyController.php @@ -15,9 +15,13 @@ class StrategyController extends Controller { public function index(Request $request): View { - $strategies = Strategy::query()->when($request->query('keywords'), function (Builder $builder, $keywords) { + $keywords = $request->query('keywords'); + $strategies = Strategy::query()->when($keywords, function (Builder $builder, $keywords) { $builder->where('name', 'like', "%{$keywords}%")->orWhere('intro', 'like', "%{$keywords}%"); })->withCount('images')->withSum('images', 'size')->latest()->paginate(); + + $strategies->appends(compact('keywords')); + return view('admin.strategy.index', compact('strategies')); } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 49bf9afa0..b55d112f0 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -19,15 +19,19 @@ class UserController extends Controller public function index(Request $request): View { $status = $request->query('status'); + $keywords = $request->query('keywords'); $users = User::query()->when($status > -1, function (Builder $builder) use ($status) { $builder->where('status', $status); - })->when($request->query('keywords'), function (Builder $builder, $keywords) { + })->when($keywords, function (Builder $builder, $keywords) { $builder->where('name', 'like', "%{$keywords}%")->orWhere('email', 'like', "%{$keywords}%"); })->with('group')->withSum('images', 'size')->latest()->paginate(); $users->getCollection()->each(function (User $user) { $user->group->setVisible(['name']); }); $statuses = [-1 => '全部', 1 => '正常', 0 => '冻结']; + + $users->appends(compact('status', 'keywords')); + return view('admin.user.index', compact('users', 'statuses')); }