30 lines
1.1 KiB
PHP
30 lines
1.1 KiB
PHP
<?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_brand_models', static function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name')->nullable()->comment('Наименование');
|
|
$table->integer('year')->nullable()->comment('Год выпуска');
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->unsignedBigInteger('brand_id')->nullable()->comment('Марка');
|
|
$table->foreign('brand_id')->references('id')->on('pipi_auto_brands');
|
|
$table->unsignedBigInteger('tariff_id')->nullable()->comment('Тариф');
|
|
$table->foreign('tariff_id')->references('id')->on('pipi_auto_tariffs');
|
|
});
|
|
}
|
|
}
|
|
};
|