改进模型

This commit is contained in:
Wisp X
2022-02-25 09:25:44 +08:00
parent c1de4d03d0
commit 27ccdb4c73
9 changed files with 27 additions and 5 deletions
@@ -16,7 +16,7 @@ class StrategyController extends Controller
public function index(Request $request): View
{
$strategies = Strategy::query()->when($request->query('keywords'), function (Builder $builder, $keywords) {
$builder->whereRaw("concat(ifnull(name,''),ifnull(intro,'')) like ?",["%{$keywords}%"]);
$builder->where('name', 'like', "%{$keywords}%")->orWhere('intro', 'like', "%{$keywords}%");
})->withCount('images')->withSum('images', 'size')->latest()->paginate();
return view('admin.strategy.index', compact('strategies'));
}