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,13 @@
<?php
use Modules\Coupon\Entities\Coupon;
$factory->define(Coupon::class, function (Faker\Generator $faker) {
return [
'name' => $faker->word(),
'code' => $faker->word(),
'value' => $faker->randomNumber(),
'is_percent' => $faker->boolean(),
'is_active' => $faker->boolean(),
];
});

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCouponsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('coupons', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->index();
$table->decimal('value', 18, 4)->unsigned()->nullable();
$table->boolean('is_percent');
$table->boolean('free_shipping');
$table->decimal('minimum_spend', 18, 4)->unsigned()->nullable();
$table->decimal('maximum_spend', 18, 4)->unsigned()->nullable();
$table->integer('usage_limit_per_coupon')->unsigned()->nullable();
$table->integer('usage_limit_per_customer')->unsigned()->nullable();
$table->integer('used')->default(0);
$table->boolean('is_active');
$table->date('start_date')->nullable();
$table->date('end_date')->nullable();
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('coupons');
}
}

View File

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

View File

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

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCouponCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('coupon_categories', function (Blueprint $table) {
$table->integer('coupon_id')->unsigned();
$table->integer('category_id')->unsigned();
$table->boolean('exclude')->default(false);
$table->primary(['coupon_id', 'category_id', 'exclude']);
$table->foreign('coupon_id')->references('id')->on('coupons')->onDelete('cascade');
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('coupon_categories');
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Modules\Coupon\Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Coupon\Entities\Coupon;
class CouponDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(Coupon::class, 10)->create();
}
}