Edit File: 2023_10_26_000001_create_orders_table.php
<?php use App\Enums\OrderWhenEnum; use App\Enums\ProductDeliveryTypesEnum; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateOrdersTable extends Migration { public function up() { Schema::create('orders', function (Blueprint $table) { $table->id(); $table->string('order_num', 50); //! create with new order dynamic $table->foreignId('user_id')->constrained()->onDelete('cascade'); $table->foreignId('provider_id')->nullable()->constrained()->onDelete('cascade'); $table->foreignId('delegate_id')->nullable()->constrained()->onDelete('cascade'); $table->enum('order_type', array_column(OrderWhenEnum::cases(), 'value'))->default(OrderWhenEnum::IMMEDIATELY->value); $table->tinyInteger('receiving_method')->default(1) ->comment('Store=' . ProductDeliveryTypesEnum::Store->value, 'Home=' . ProductDeliveryTypesEnum::Home->value); $table->date('schedule_execution_date')->nullable(); $table->time('schedule_execution_time')->nullable(); $table->foreignId('cancellation_reason_id')->nullable()->constrained('cancel_reasons')->onDelete('cascade'); $table->foreignId('city_id')->nullable()->constrained()->onDelete('cascade'); $table->foreignId('neighborhood_id')->nullable()->constrained()->onDelete('cascade'); $table->foreignId('coupon_id')->nullable()->constrained()->onDelete('cascade'); $table->string('coupon_num')->nullable(); $table->string('coupon_type')->nullable(); $table->string('coupon_value')->nullable(); $table->double('vat_per', 9, 2)->default(0); $table->decimal('vat_amount', 9, 2)->default(0); $table->decimal('total_products', 9, 2)->default(0); $table->decimal('coupon_amount', 9, 2)->default(0); $table->decimal('delivery_price', 9, 2)->default(0); $table->decimal('final_total', 9, 2)->default(0); $table->decimal('admin_commission_value', 9, 2)->default(0)->comment('sum of '); $table->decimal('commission_ratio_from_provider', 9, 2)->default(0); $table->decimal('provider_due_amount', 9, 2)->default(0); $table->decimal('commission_ratio_from_delegate', 9, 2)->default(0); $table->decimal('delegate_due_amount', 9, 2)->default(0); $table->decimal('commission_value_from_provider', 10, 2)->default(0); $table->decimal('commission_value_from_delegate', 10, 2)->default(0); $table->foreignId('room_id')->nullable()->constrained('rooms')->onDelete('cascade'); $table->integer('status')->default(0); $table->integer('pay_type')->default(0); $table->integer('pay_status')->default(0); $table->json('pay_data')->nullable(); $table->decimal('lat')->nullable(); $table->decimal('lng')->nullable(); $table->string('map_desc', 255)->nullable(); $table->text('notes')->nullable(); // when receive order in store $table->string('car_color')->nullable(); $table->string('car_model')->nullable(); $table->string('car_plat_number')->nullable(); $table->text('receiving_in_store_notes')->nullable(); $table->timestamp('order_picked_at')->nullable(); // Provider Time for Order Approval Before Cancellation $table->integer('expiry_period')->nullable(); $table->timestamp('expired_at')->nullable(); // for settlement system $table->boolean('is_settlement')->default(false); $table->timestamps(); }); } public function down() { Schema::dropIfExists('orders'); } }
Back to File Manager