Кузовы

pull/7/head
Rustem 2025-03-27 10:35:34 +05:00
parent 384de527c6
commit 57eedf2cd4
7 changed files with 187 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class PipiCarInstallCommands extends InstallCommand
$this->packages = [ $this->packages = [
'main', // Главная страница 'main', // Главная страница
'auto_brands', // Бренд авто 'auto_brands', // Бренд авто
'auto_bodywork', // Кузов авто
'auto_colors', // Цвета авто 'auto_colors', // Цвета авто
'auto_types', // Типы авто 'auto_types', // Типы авто
'auto_equipment', // Комплектация авто 'auto_equipment', // Комплектация авто

View File

@ -187,6 +187,7 @@ class MobileApiController extends Controller
$started_at = $request->query('started_at'); $started_at = $request->query('started_at');
$ended_at = $request->query('ended_at'); $ended_at = $request->query('ended_at');
$class = $request->query('class'); $class = $request->query('class');
$bodywork = $request->query('bodywork');
$marks = UniModel::model('pipi_brand_models')->get(); $marks = UniModel::model('pipi_brand_models')->get();
$availableMarks = []; $availableMarks = [];
@ -195,6 +196,10 @@ class MobileApiController extends Controller
$class_id = UniModel::model('pipi_auto_classes')->where('name', $class)->first()->id; $class_id = UniModel::model('pipi_auto_classes')->where('name', $class)->first()->id;
$marks = $marks->where('class_id', $class_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) { foreach ($marks as $mark) {
if ($mark->name === 'Ввод остатков') { if ($mark->name === 'Ввод остатков') {
continue; continue;
@ -207,6 +212,8 @@ class MobileApiController extends Controller
$brand = UniModel::model('pipi_auto_brands')->find($mark->brand_id); $brand = UniModel::model('pipi_auto_brands')->find($mark->brand_id);
$tariffs = UniModel::model('pipi_auto_tariffs')->where('model_id', $mark->id)->get(); $tariffs = UniModel::model('pipi_auto_tariffs')->where('model_id', $mark->id)->get();
$equipment = UniModel::model('pipi_auto_equipment')->where('id', $mark->equipment_id)->first(); $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; $path = null;
if ($mark?->photo_id) { if ($mark?->photo_id) {
@ -234,6 +241,8 @@ class MobileApiController extends Controller
'hp' => $mark?->hp ?? '1.6', 'hp' => $mark?->hp ?? '1.6',
'engine_capacity' => $mark?->engine_capacity ?? '1591', 'engine_capacity' => $mark?->engine_capacity ?? '1591',
'fuel_tank' => $mark?->fuel_tank ?? '50', 'fuel_tank' => $mark?->fuel_tank ?? '50',
'class' => $class->name ?? 'Эконом',
'bodywork' => $class->name ?? 'Седан',
'conditioner' => $mark?->conditioner, 'conditioner' => $mark?->conditioner,
'photo' => $path, 'photo' => $path,
'tariffs' => $tariffs_new 'tariffs' => $tariffs_new

View File

@ -0,0 +1,9 @@
{
"admin": [
"default",
"add",
"show",
"edit",
"delete"
]
}

View File

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

View File

@ -0,0 +1,23 @@
<?php
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
$segments = Segment::listActive();
foreach ($segments as $segment) {
Schema::connection($segment->connector)->create('pipi_auto_bodywork', static function (Blueprint $table) {
$table->id();
$table->string('name')->nullable()->comment('Наименование');
$table->timestamps();
$table->softDeletes();
});
}
}
};

View File

@ -0,0 +1,38 @@
<?php
use A7kz\Platform\Models\UniModel;
use A7kz\Platform\Modules\Platform\Core\Facades\Core;
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
use Carbon\Carbon;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
use \A7kz\Platform\Commands\InstallScript;
return new class extends \A7kz\Platform\Commands\InstallScript {
public function install($module_name, $module_version)
{
}
public function update($module_name, $module_version): void
{
$this->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();
});
}
}
}
};

View File

@ -67,6 +67,11 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
$table->unsignedBigInteger('photo_id')->nullable()->comment('Фото'); $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('Кузов');
});
}
} }
} }
}; };