From 682ef73690d1e623c5f45ca11bc0c7a336a5f32e Mon Sep 17 00:00:00 2001 From: Rustem Date: Tue, 25 Mar 2025 22:02:30 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B0=D0=BF=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MobileApiController.php | 12 ++++++------ modules/brand_models/app.json | 20 ++++++++++++++++++++ modules/brand_models/script.php | 6 ++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/MobileApiController.php b/app/Http/Controllers/MobileApiController.php index 6f196cf..f9220a9 100644 --- a/app/Http/Controllers/MobileApiController.php +++ b/app/Http/Controllers/MobileApiController.php @@ -188,14 +188,13 @@ class MobileApiController extends Controller $ended_at = $request->query('ended_at'); $class = $request->query('class'); - $marks = UniModel::model('pipi_brand_models'); - if ($class) { - $class_id = UniModel::model('pipi_auto_class')->firstWhere('name', $class)->id; - $marks = $marks->where('class_id', $class_id); - } - $marks->get(); + $marks = UniModel::model('pipi_brand_models')->get(); $availableMarks = []; + if ($class) { + $class_id = UniModel::model('pipi_auto_classes')->where('name', $class)->first()->id; + $marks = $marks->where('class_id', $class_id); + } foreach ($marks as $mark) { if ($mark->name === 'Ввод остатков') { continue; @@ -232,6 +231,7 @@ class MobileApiController extends Controller 'engine_capacity' => $mark?->engine_capacity ?? 1591, 'fuel_tank' => $mark?->fuel_tank ?? 50, 'conditioner' => $mark?->conditioner, + 'photo' => lurl('/download/'.$mark?->photo_id), 'tariffs' => $tariffs_new ]; } diff --git a/modules/brand_models/app.json b/modules/brand_models/app.json index c2b552d..b202641 100644 --- a/modules/brand_models/app.json +++ b/modules/brand_models/app.json @@ -40,6 +40,10 @@ "conditioner": { "type": "bool" }, + "photo_id": { + "type": "int", + "validation": "nullable|int" + }, "brand_id": { "type": "foreign", "table": "pipi_auto_brands", @@ -359,6 +363,14 @@ "name": "conditioner", "label": "Кондиционер" } + }, + { + "size": 12, + "input": { + "name": "photo_id", + "label": "Фото", + "type": "file" + } } ] } @@ -448,6 +460,14 @@ "name": "conditioner", "label": "Кондиционер" } + }, + { + "size": 12, + "input": { + "name": "photo_id", + "label": "Фото", + "type": "file" + } } ] }, diff --git a/modules/brand_models/script.php b/modules/brand_models/script.php index a4ef8d6..0a2ba0f 100644 --- a/modules/brand_models/script.php +++ b/modules/brand_models/script.php @@ -61,6 +61,12 @@ return new class extends \A7kz\Platform\Commands\InstallScript { $table->unsignedBigInteger('class_id')->nullable()->comment('Класс'); }); } + + if (!Schema::connection($segment->connector)->hasColumn('pipi_brand_models', 'photo_id')) { + Schema::connection($segment->connector)->table('pipi_brand_models', function ($table) { + $table->unsignedBigInteger('photo_id')->nullable()->comment('Фото'); + }); + } } } };