Skip to content

Commit

Permalink
Merge 00f2c54 into 3c2d314
Browse files Browse the repository at this point in the history
  • Loading branch information
emptynick committed Apr 1, 2021
2 parents 3c2d314 + 00f2c54 commit 43c3f35
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Http/Controllers/VoyagerBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,9 @@ public function index(Request $request)

$searchNames = [];
if ($dataType->server_side) {
$searchable = SchemaManager::describeTable(app($dataType->model_name)->getTable())->pluck('name')->toArray();
$dataRow = Voyager::model('DataRow')->whereDataTypeId($dataType->id)->get();
foreach ($searchable as $key => $value) {
$field = $dataRow->where('field', $value)->first();
$displayName = ucwords(str_replace('_', ' ', $value));
if ($field !== null) {
$displayName = $field->getTranslatedAttribute('display_name');
}
$searchNames[$value] = $displayName;
}
$searchNames = $dataType->browseRows->mapWithKeys(function ($row) {
return [$row['field'] => $row->getTranslatedAttribute('display_name')];
});
}

$orderBy = $request->get('order_by', $dataType->order_column);
Expand Down Expand Up @@ -100,7 +93,9 @@ public function index(Request $request)
$row->details->model::where($row->details->label, $search_filter, $search_value)->pluck('id')->toArray()
);
} else {
$query->where($searchField, $search_filter, $search_value);
if ($dataType->browseRows->pluck('field')->contains($search->key)) {
$query->where($searchField, $search_filter, $search_value);
}
}
}

Expand Down

0 comments on commit 43c3f35

Please sign in to comment.