|
|
@@ -17,8 +17,8 @@ class ImportController extends Controller
|
|
|
'id' => 'import',
|
|
|
'header' => [
|
|
|
'id' => 'ID',
|
|
|
- 'type' => 'Тип',
|
|
|
- 'status' => 'Статус',
|
|
|
+ 'type_label' => 'Тип',
|
|
|
+ 'status_label' => 'Статус',
|
|
|
'created_at' => 'Создано',
|
|
|
'updated_at' => 'Изменено',
|
|
|
],
|
|
|
@@ -36,7 +36,7 @@ class ImportController extends Controller
|
|
|
$model = new Import;
|
|
|
// fill filters
|
|
|
$this->data['ranges'] = [];
|
|
|
- $this->createFilters($model, 'type', 'status');
|
|
|
+ $this->createImportFilters($model);
|
|
|
$this->createDateFilters($model, 'created_at', 'updated_at');
|
|
|
|
|
|
$q = $model::query();
|
|
|
@@ -85,4 +85,32 @@ class ImportController extends Controller
|
|
|
return view('import.show', $this->data);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Создание фильтров с переведёнными значениями type и status
|
|
|
+ */
|
|
|
+ protected function createImportFilters(Import $model): void
|
|
|
+ {
|
|
|
+ // Фильтр по типу
|
|
|
+ $uniqueTypes = $model::query()->distinct()->pluck('type')->toArray();
|
|
|
+ $typeValues = [];
|
|
|
+ foreach ($uniqueTypes as $type) {
|
|
|
+ $typeValues[$type] = Import::TYPE_LABELS[$type] ?? $type;
|
|
|
+ }
|
|
|
+ $this->data['filters']['type'] = [
|
|
|
+ 'title' => 'Тип',
|
|
|
+ 'values' => $typeValues,
|
|
|
+ ];
|
|
|
+
|
|
|
+ // Фильтр по статусу
|
|
|
+ $uniqueStatuses = $model::query()->distinct()->pluck('status')->toArray();
|
|
|
+ $statusValues = [];
|
|
|
+ foreach ($uniqueStatuses as $status) {
|
|
|
+ $statusValues[$status] = Import::STATUS_LABELS[$status] ?? $status;
|
|
|
+ }
|
|
|
+ $this->data['filters']['status'] = [
|
|
|
+ 'title' => 'Статус',
|
|
|
+ 'values' => $statusValues,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
}
|