From 57eedf2cd4dba6dca029a36da0bda8b73944f276 Mon Sep 17 00:00:00 2001 From: Rustem Date: Thu, 27 Mar 2025 10:35:34 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9A=D1=83=D0=B7=D0=BE=D0=B2=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/PipiCarInstallCommands.php | 1 + app/Http/Controllers/MobileApiController.php | 9 ++ modules/auto_bodywork/access.json | 9 ++ modules/auto_bodywork/app.json | 102 +++++++++++++++++++ modules/auto_bodywork/migrate.php | 23 +++++ modules/auto_bodywork/script.php | 38 +++++++ modules/brand_models/script.php | 5 + 7 files changed, 187 insertions(+) create mode 100644 modules/auto_bodywork/access.json create mode 100644 modules/auto_bodywork/app.json create mode 100644 modules/auto_bodywork/migrate.php create mode 100644 modules/auto_bodywork/script.php diff --git a/app/Console/PipiCarInstallCommands.php b/app/Console/PipiCarInstallCommands.php index 83524cd..1de8f98 100644 --- a/app/Console/PipiCarInstallCommands.php +++ b/app/Console/PipiCarInstallCommands.php @@ -25,6 +25,7 @@ class PipiCarInstallCommands extends InstallCommand $this->packages = [ 'main', // Главная страница 'auto_brands', // Бренд авто + 'auto_bodywork', // Кузов авто 'auto_colors', // Цвета авто 'auto_types', // Типы авто 'auto_equipment', // Комплектация авто diff --git a/app/Http/Controllers/MobileApiController.php b/app/Http/Controllers/MobileApiController.php index 5a7f311..c2d290b 100644 --- a/app/Http/Controllers/MobileApiController.php +++ b/app/Http/Controllers/MobileApiController.php @@ -187,6 +187,7 @@ class MobileApiController extends Controller $started_at = $request->query('started_at'); $ended_at = $request->query('ended_at'); $class = $request->query('class'); + $bodywork = $request->query('bodywork'); $marks = UniModel::model('pipi_brand_models')->get(); $availableMarks = []; @@ -195,6 +196,10 @@ class MobileApiController extends Controller $class_id = UniModel::model('pipi_auto_classes')->where('name', $class)->first()->id; $marks = $marks->where('class_id', $class_id); } + if ($bodywork) { + $bodywork_id = UniModel::model('pipi_auto_bodywork')->where('name', $bodywork)->first()->id; + $marks = $marks->where('bodywork_id', $bodywork_id); + } foreach ($marks as $mark) { if ($mark->name === 'Ввод остатков') { continue; @@ -207,6 +212,8 @@ class MobileApiController extends Controller $brand = UniModel::model('pipi_auto_brands')->find($mark->brand_id); $tariffs = UniModel::model('pipi_auto_tariffs')->where('model_id', $mark->id)->get(); $equipment = UniModel::model('pipi_auto_equipment')->where('id', $mark->equipment_id)->first(); + $class = UniModel::model('pipi_auto_classes')->find($mark->class_id); + $bodywork = UniModel::model('pipi_auto_classes')->find($mark->bodywork_id); $path = null; if ($mark?->photo_id) { @@ -234,6 +241,8 @@ class MobileApiController extends Controller 'hp' => $mark?->hp ?? '1.6', 'engine_capacity' => $mark?->engine_capacity ?? '1591', 'fuel_tank' => $mark?->fuel_tank ?? '50', + 'class' => $class->name ?? 'Эконом', + 'bodywork' => $class->name ?? 'Седан', 'conditioner' => $mark?->conditioner, 'photo' => $path, 'tariffs' => $tariffs_new diff --git a/modules/auto_bodywork/access.json b/modules/auto_bodywork/access.json new file mode 100644 index 0000000..9e4f179 --- /dev/null +++ b/modules/auto_bodywork/access.json @@ -0,0 +1,9 @@ +{ + "admin": [ + "default", + "add", + "show", + "edit", + "delete" + ] +} diff --git a/modules/auto_bodywork/app.json b/modules/auto_bodywork/app.json new file mode 100644 index 0000000..65d6490 --- /dev/null +++ b/modules/auto_bodywork/app.json @@ -0,0 +1,102 @@ +{ + "module": "pipicar", + "name": "pipicar.auto_bodywork", + "type": "crud", + "title": "Классы автомобилей", + "withHeader": false, + "data": { + "table": "pipi_auto_bodywork", + "pk": "id", + "limit": 25, + "segment": true, + "timestamp": false, + "fields": { + "id": { + "type": "pk" + }, + "name": { + "type": "string" + } + } + }, + "ui": { + "grid": { + "title": "Кузовы автомобилей", + "component": "App.components.Grid", + "cols": [ + { + "name": "name", + "caption": "Название кузова" + } + ], + "action": { + "head": [], + "row": [ + "edit", + "delete" + ] + }, + "filter": { + "template": "app.base.crud.filter", + "rows": [ + { + "cols": [ + { + "size": 6, + "input": { + "name": "name", + "label": "Название кузова" + } + } + ] + } + ] + } + }, + "forms": { + "add": { + "title": "Добавление кузова", + "template": "app.base.crud.form", + "component": "App.components.Show", + "form": { + "submits": "struct:crud.form.edit.submits", + "rows": [ + { + "cols": [ + { + "size": 12, + "input": { + "name": "name", + "label": "Название кузова" + } + } + ] + } + ] + } + }, + "edit": { + "title": "Редактирование кузова", + "template": "app.base.crud.form", + "component": "App.components.Show", + "form": { + "rows": [ + { + "cols": [ + { + "size": 12, + "input": { + "name": "name", + "label": "Название кузова" + } + } + ] + } + ], + "submits": "struct:crud.form.edit.submits" + } + } + } + }, + "actions": "struct:crud.actions" +} diff --git a/modules/auto_bodywork/migrate.php b/modules/auto_bodywork/migrate.php new file mode 100644 index 0000000..db6802f --- /dev/null +++ b/modules/auto_bodywork/migrate.php @@ -0,0 +1,23 @@ +connector)->create('pipi_auto_bodywork', static function (Blueprint $table) { + $table->id(); + $table->string('name')->nullable()->comment('Наименование'); + $table->timestamps(); + $table->softDeletes(); + }); + } + } +}; diff --git a/modules/auto_bodywork/script.php b/modules/auto_bodywork/script.php new file mode 100644 index 0000000..63d45f3 --- /dev/null +++ b/modules/auto_bodywork/script.php @@ -0,0 +1,38 @@ +upgrade(); + } + + private function upgrade(): void + { + $segments = Segment::listActive(); + foreach ($segments as $segment) { + if (!Schema::connection($segment->connector)->hasTable('pipi_auto_bodywork')) { + Schema::connection($segment->connector)->create('pipi_auto_bodywork', static function (Blueprint $table) { + $table->id(); + $table->string('name')->nullable()->comment('Наименование'); + $table->timestamps(); + $table->softDeletes(); + }); + } + } + } +}; diff --git a/modules/brand_models/script.php b/modules/brand_models/script.php index 0a2ba0f..3ca6ca9 100644 --- a/modules/brand_models/script.php +++ b/modules/brand_models/script.php @@ -67,6 +67,11 @@ return new class extends \A7kz\Platform\Commands\InstallScript { $table->unsignedBigInteger('photo_id')->nullable()->comment('Фото'); }); } + if (!Schema::connection($segment->connector)->hasColumn('pipi_brand_models', 'bodywork_id')) { + Schema::connection($segment->connector)->table('pipi_brand_models', function ($table) { + $table->unsignedBigInteger('bodywork_id')->nullable()->comment('Кузов'); + }); + } } } };