Files
ladill-pos/database/migrations/2026_06_26_100000_create_pos_tables.php
isaaccladandCursor e5d2b84388
Deploy Ladill Mini / deploy (push) Successful in 23s
Add Ladill POS v1 — register, Pay checkout, and commerce links.
Staff-facing counter register at pos.ladill.com with catalog cart, cash and
MoMo/card checkout via Ladill Pay, CRM timeline/import, invoice prefill, and
Merchant catalog import.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 22:52:24 +00:00

77 lines
3.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('pos_locations', function (Blueprint $table) {
$table->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');
}
};