File "2024_10_29_152841_create_coupons_table.php"

Full Path: /home/tecassol/public_html/tecas-solar.ma/database/migrations/2024_10_29_152841_create_coupons_table.php
File size: 1.47 KB
MIME-type: text/x-php
Charset: utf-8

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('coupons', function (Blueprint $table) {
            $table->id();
            $table->string('code', 255)->unique();
            $table->string('type')->default(1);
            $table->decimal('discount_percentage', 5, 2)->nullable();
            $table->decimal('discount_amount', 10, 2)->nullable();
            $table->string('apply_to')->default(1);
            $table->integer('requirement_type')->default(1);
            $table->string('eligibility')->default(1);
            // Minimum requirements
            $table->decimal('min_required_amount', 10, 2)->nullable();
            $table->integer('min_required_items')->nullable();
            // Usage limits
            $table->integer('max_uses')->nullable();
            $table->boolean('usage_limit_per_user')->default(false);
            $table->integer('total_uses')->default(0);
            // Validity
            $table->boolean('is_active')->default(true);
            $table->timestamp('valid_from')->nullable();
            $table->timestamp('valid_until')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('coupons');
    }
};