Explorar el Código

修复表格关联字段搜索bug

jqh hace 4 años
padre
commit
a0dc962a10
Se han modificado 2 ficheros con 8 adiciones y 1 borrados
  1. 6 1
      src/Support/Helper.php
  2. 2 0
      tests/Controllers/UserController.php

+ 6 - 1
src/Support/Helper.php

@@ -795,7 +795,12 @@ class Helper
             return;
         }
 
-        static::withRelationQuery($model, $column, $query, $params);
+        $method = $query === 'orWhere' ? 'orWhere' : 'where';
+        $subQuery = $query === 'orWhere' ? 'where' : $query;
+
+        $model->$method(function () use ($model, $column, $subQuery, $params) {
+            static::withRelationQuery($model, $column, $subQuery, $params);
+        });
     }
 
     /**

+ 2 - 0
tests/Controllers/UserController.php

@@ -115,6 +115,8 @@ class UserController extends AdminController
         $grid->created_at();
         $grid->updated_at();
 
+        $grid->quickSearch('profile.postcode', 'username');
+
         $grid->filter(function (Grid\Filter $filter) {
             $filter->equal('id');
             $filter->like('username');