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

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');
$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
];
}

View File

@ -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"
}
}
]
},

View File

@ -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('Фото');
});
}
}
}
};