first upload all files
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user