我的图片支持关键字搜索

This commit is contained in:
Wisp X
2021-12-23 22:49:40 +08:00
parent bb78e935a8
commit 15685d664f
4 changed files with 33 additions and 4 deletions
@@ -38,6 +38,8 @@ class ImageController extends Controller
default:
$builder->latest();
}
})->when($request->query('keyword'), function (Builder $builder, $keyword) {
$builder->whereRaw("concat(IFNULL(origin_name,''),IFNULL(alias_name,'')) like ?", ["%{$keyword}%"]);
})->paginate(40);
$images->getCollection()->each(function (Image $image) {
$image->human_date = $image->created_at->diffForHumans();