first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
use Faker\Generator as Faker;
use Modules\Option\Entities\Option;
use Modules\Option\Entities\OptionValue;
$factory->define(OptionValue::class, function (Faker $faker) {
return [
'option_id' => function () {
return factory(Option::class)->create()->id;
},
'name' => $faker->word(),
'price' => $faker->randomNumber(),
'price_type' => $faker->randomElement(['fixed', 'percent']),
];
});
$factory->define(Option::class, function (Faker $faker) {
return [
'name' => $faker->word(),
'type' => $faker->randomElement(['field', 'dropdown']),
'is_required' => $faker->boolean(),
];
});

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('options', function (Blueprint $table) {
$table->increments('id');
$table->string('type');
$table->boolean('is_required');
$table->boolean('is_global')->default(true);
$table->integer('position')->unsigned()->nullable();
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('options');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOptionTranslationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('option_translations', function (Blueprint $table) {
$table->increments('id');
$table->integer('option_id')->unsigned();
$table->string('locale');
$table->string('name');
$table->unique(['option_id', 'locale']);
$table->foreign('option_id')->references('id')->on('options')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('option_translations');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOptionValuesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('option_values', function (Blueprint $table) {
$table->increments('id');
$table->integer('option_id')->unsigned()->index();
$table->decimal('price', 18, 4)->unsigned()->nullable();
$table->string('price_type', 10);
$table->integer('position')->unsigned();
$table->timestamps();
$table->foreign('option_id')->references('id')->on('options')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('option_values');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOptionValueTranslationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('option_value_translations', function (Blueprint $table) {
$table->increments('id');
$table->integer('option_value_id')->unsigned();
$table->string('locale');
$table->string('label');
$table->unique(['option_value_id', 'locale']);
$table->foreign('option_value_id')->references('id')->on('option_values')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('option_value_translations');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductOptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_options', function (Blueprint $table) {
$table->integer('product_id')->unsigned();
$table->integer('option_id')->unsigned();
$table->primary(['product_id', 'option_id']);
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
$table->foreign('option_id')->references('id')->on('options')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_options');
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Modules\Option\Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Option\Entities\Option;
use Modules\Option\Entities\OptionValue;
class OptionDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(Option::class, 10)
->create()
->each(function ($option) {
$times = $option->type === 'dropdown' ? 5 : 1;
factory(OptionValue::class, $times)->create(['option_id' => $option->id]);
});
}
}