id(); $table->string('owner_ref')->index(); $table->string('name'); $table->string('currency', 3)->default('GHS'); $table->text('receipt_footer')->nullable(); $table->timestamps(); }); Schema::create('pos_products', function (Blueprint $table) { $table->id(); $table->string('owner_ref')->index(); $table->foreignId('location_id')->nullable()->constrained('pos_locations')->nullOnDelete(); $table->string('name'); $table->string('sku')->nullable(); $table->unsignedInteger('price_minor'); $table->string('currency', 3)->default('GHS'); $table->boolean('is_active')->default(true); $table->timestamps(); $table->index(['owner_ref', 'is_active']); }); Schema::create('pos_sales', function (Blueprint $table) { $table->id(); $table->string('owner_ref')->index(); $table->foreignId('location_id')->nullable()->constrained('pos_locations')->nullOnDelete(); $table->string('reference')->unique(); $table->string('status')->default('pending'); // pending | paid | failed | cancelled $table->string('payment_method')->default('pay'); // pay | cash $table->unsignedBigInteger('pay_order_id')->nullable(); $table->string('payment_reference')->nullable()->index(); $table->string('customer_name')->nullable(); $table->string('customer_email')->nullable(); $table->string('customer_phone', 40)->nullable(); $table->unsignedBigInteger('crm_customer_id')->nullable(); $table->unsignedInteger('subtotal_minor')->default(0); $table->unsignedInteger('total_minor')->default(0); $table->string('currency', 3)->default('GHS'); $table->timestamp('paid_at')->nullable(); $table->timestamps(); $table->index(['owner_ref', 'status', 'created_at']); }); Schema::create('pos_sale_lines', function (Blueprint $table) { $table->id(); $table->foreignId('pos_sale_id')->constrained('pos_sales')->cascadeOnDelete(); $table->foreignId('product_id')->nullable()->constrained('pos_products')->nullOnDelete(); $table->string('name'); $table->unsignedInteger('unit_price_minor'); $table->unsignedInteger('quantity')->default(1); $table->unsignedInteger('line_total_minor'); $table->unsignedSmallInteger('position')->default(0); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('pos_sale_lines'); Schema::dropIfExists('pos_sales'); Schema::dropIfExists('pos_products'); Schema::dropIfExists('pos_locations'); } };