File: /home/armgroup/libs/database/migrations/2021_10_31_101503_create_discounts_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDiscountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('discounts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->onUpdate('cascade')->onDelete('set null');
$table->string('title');
$table->string('code')->unique();
$table->unsignedTinyInteger('type')->default(\App\Enums\DiscountType::PERCENT);
$table->unsignedBigInteger('amount');
$table->unsignedBigInteger('minimum_order_price')->nullable();
$table->unsignedTinyInteger('usage')->nullable();
$table->dateTime('start_date');
$table->dateTime('end_date');
$table->string('discountable_type');
$table->text('discountable_items')->nullable();
$table->unsignedTinyInteger('notification_type');
$table->boolean('is_general')->default(false);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('discounts');
}
}