fix(mobile): resolve timesheet and p2h mobile search button and space-insensitive matching

This commit is contained in:
Ray1111-aa
2026-10-27 08:34:34 +07:00
parent 58f1801810
commit c8d14c9470
8 changed files with 157 additions and 38 deletions
+10 -2
View File
@@ -32,11 +32,19 @@ class P2hFormController extends Controller
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where(function ($q) use ($search) {
$cleanSearch = preg_replace('/[^a-zA-Z0-9]/', '', $search);
$query->where(function ($q) use ($search, $cleanSearch) {
$q->where('code', 'like', "%{$search}%")
->orWhere('brand_type', 'like', "%{$search}%")
->orWhere('unit_category', 'like', "%{$search}%")
->orWhere('location', 'like', "%{$search}%");
->orWhere('location', 'like', "%{$search}%")
->orWhere('license_plate', 'like', "%{$search}%");
if (!empty($cleanSearch)) {
$q->orWhereRaw("REPLACE(REPLACE(code, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"])
->orWhereRaw("REPLACE(REPLACE(license_plate, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"]);
}
});
}