Browse Source

优化告警信息关键字搜索

master
wanghongjun 3 days ago
parent
commit
be0ee6c043
  1. 21
      app/Http/Controllers/Admin/ParkingAlarmInformationController.php

21
app/Http/Controllers/Admin/ParkingAlarmInformationController.php

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Exceptions\CustomException; use App\Exceptions\CustomException;
use App\Models\ParkingAlarmInformation; use App\Models\ParkingAlarmInformation;
use App\Services\AdminTranslationService;
use App\Services\ApiResponseService; use App\Services\ApiResponseService;
use App\Services\ParkingAlarmInformationService; use App\Services\ParkingAlarmInformationService;
use Exception; use Exception;
@ -41,11 +42,29 @@ class ParkingAlarmInformationController extends BaseController
if ($request->has('keyword')) { if ($request->has('keyword')) {
$keyword = $request->input('keyword'); $keyword = $request->input('keyword');
if ($keyword) { if ($keyword) {
$query->where(function ($q) use ($keyword) { $type_id = 0;
$nameTypeId = AdminTranslationService::getTypeId(100, $keyword);
if ($nameTypeId) {
$type_id = $nameTypeId;
}
$conditionTypeId = AdminTranslationService::getTypeId(101, $keyword);
if ($conditionTypeId) {
$type_id = $conditionTypeId;
}
$contentTypeId = AdminTranslationService::getTypeId(102, $keyword);
if ($contentTypeId) {
$type_id = $contentTypeId;
}
$remarkTypeId = AdminTranslationService::getTypeId(103, $keyword);
if ($remarkTypeId) {
$type_id = $remarkTypeId;
}
$query->where(function ($q) use ($keyword, $type_id) {
$q->orWhere('name', $keyword); $q->orWhere('name', $keyword);
$q->orWhere('condition', $keyword); $q->orWhere('condition', $keyword);
$q->orWhere('content', $keyword); $q->orWhere('content', $keyword);
$q->orWhere('remark', $keyword); $q->orWhere('remark', $keyword);
$q->orWhere('id', $type_id);
}); });
} }
} }

Loading…
Cancel
Save