Доработка апи

pull/6/head
Rustem 2025-03-25 22:02:30 +05:00
parent 3fddaba582
commit 682ef73690
3 changed files with 32 additions and 6 deletions

View File

@ -188,14 +188,13 @@ class MobileApiController extends Controller
$ended_at = $request->query('ended_at'); $ended_at = $request->query('ended_at');
$class = $request->query('class'); $class = $request->query('class');
$marks = UniModel::model('pipi_brand_models'); $marks = UniModel::model('pipi_brand_models')->get();
if ($class) {
$class_id = UniModel::model('pipi_auto_class')->firstWhere('name', $class)->id;
$marks = $marks->where('class_id', $class_id);
}
$marks->get();
$availableMarks = []; $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) { foreach ($marks as $mark) {
if ($mark->name === 'Ввод остатков') { if ($mark->name === 'Ввод остатков') {
continue; continue;
@ -232,6 +231,7 @@ class MobileApiController extends Controller
'engine_capacity' => $mark?->engine_capacity ?? 1591, 'engine_capacity' => $mark?->engine_capacity ?? 1591,
'fuel_tank' => $mark?->fuel_tank ?? 50, 'fuel_tank' => $mark?->fuel_tank ?? 50,
'conditioner' => $mark?->conditioner, 'conditioner' => $mark?->conditioner,
'photo' => lurl('/download/'.$mark?->photo_id),
'tariffs' => $tariffs_new 'tariffs' => $tariffs_new
]; ];
} }

View File

@ -40,6 +40,10 @@
"conditioner": { "conditioner": {
"type": "bool" "type": "bool"
}, },
"photo_id": {
"type": "int",
"validation": "nullable|int"
},
"brand_id": { "brand_id": {
"type": "foreign", "type": "foreign",
"table": "pipi_auto_brands", "table": "pipi_auto_brands",
@ -359,6 +363,14 @@
"name": "conditioner", "name": "conditioner",
"label": "Кондиционер" "label": "Кондиционер"
} }
},
{
"size": 12,
"input": {
"name": "photo_id",
"label": "Фото",
"type": "file"
}
} }
] ]
} }
@ -448,6 +460,14 @@
"name": "conditioner", "name": "conditioner",
"label": "Кондиционер" "label": "Кондиционер"
} }
},
{
"size": 12,
"input": {
"name": "photo_id",
"label": "Фото",
"type": "file"
}
} }
] ]
}, },

View File

@ -61,6 +61,12 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
$table->unsignedBigInteger('class_id')->nullable()->comment('Класс'); $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('Фото');
});
}
} }
} }
}; };