Initial Ladill Merchant app with Gitea deploy pipeline.

Shop, menu, and booking storefronts with OIDC SSO, Pay checkout, and merchant.ladill.com deployment workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-09 23:05:21 +00:00
co-authored by Cursor
commit f718b9cfbf
311 changed files with 38972 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,52 @@
<?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
{
// Local mirror of the platform identity, keyed by public_id (OIDC sub).
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->uuid('public_id')->unique();
$table->string('name')->nullable();
$table->string('email')->unique();
$table->string('avatar_url')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,101 @@
<?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('qr_wallets', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
$table->decimal('credit_balance', 10, 4)->default(0);
$table->unsignedInteger('qr_codes_total')->default(0);
$table->unsignedBigInteger('scans_total')->default(0);
$table->string('status', 20)->default('active');
$table->timestamps();
});
Schema::create('qr_documents', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('title')->nullable();
$table->string('disk', 32)->default('qr');
$table->string('path');
$table->string('mime_type', 128)->default('application/pdf');
$table->unsignedBigInteger('size_bytes')->default(0);
$table->unsignedSmallInteger('page_count')->nullable();
$table->timestamps();
$table->index(['user_id', 'created_at']);
});
Schema::create('qr_codes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('short_code', 16)->unique();
$table->string('type', 32);
$table->string('label');
$table->text('destination_url')->nullable();
$table->foreignId('qr_document_id')->nullable()->constrained('qr_documents')->nullOnDelete();
$table->json('payload')->nullable();
$table->boolean('is_active')->default(true);
$table->string('png_path')->nullable();
$table->string('svg_path')->nullable();
$table->unsignedBigInteger('scans_total')->default(0);
$table->unsignedBigInteger('unique_scans_total')->default(0);
$table->timestamp('last_scanned_at')->nullable();
$table->timestamp('destination_updated_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'created_at']);
$table->index(['user_id', 'is_active']);
});
Schema::create('qr_transactions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('qr_wallet_id')->constrained()->cascadeOnDelete();
$table->foreignId('qr_code_id')->nullable()->constrained()->nullOnDelete();
$table->string('type', 16);
$table->decimal('amount_ghs', 10, 4);
$table->decimal('balance_after_ghs', 10, 4);
$table->string('reference')->nullable()->index();
$table->string('status', 20)->default('completed');
$table->string('description')->nullable();
$table->json('metadata')->nullable();
$table->timestamps();
$table->index(['qr_wallet_id', 'created_at']);
});
Schema::create('qr_scan_events', function (Blueprint $table) {
$table->id();
$table->foreignId('qr_code_id')->constrained()->cascadeOnDelete();
$table->timestamp('scanned_at');
$table->string('ip_hash', 64)->nullable();
$table->text('user_agent')->nullable();
$table->string('device_type', 32)->nullable();
$table->string('browser', 64)->nullable();
$table->string('os', 64)->nullable();
$table->string('country_code', 8)->nullable();
$table->string('referrer')->nullable();
$table->boolean('is_unique')->default(false);
$table->timestamps();
$table->index(['qr_code_id', 'scanned_at']);
$table->index(['qr_code_id', 'ip_hash']);
});
}
public function down(): void
{
Schema::dropIfExists('qr_scan_events');
Schema::dropIfExists('qr_transactions');
Schema::dropIfExists('qr_codes');
Schema::dropIfExists('qr_documents');
Schema::dropIfExists('qr_wallets');
}
};
@@ -0,0 +1,22 @@
<?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::table('qr_codes', function (Blueprint $table) {
$table->string('short_code', 32)->change();
});
}
public function down(): void
{
Schema::table('qr_codes', function (Blueprint $table) {
$table->string('short_code', 16)->change();
});
}
};
@@ -0,0 +1,33 @@
<?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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -0,0 +1,25 @@
<?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('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -0,0 +1,30 @@
<?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('qr_team_members', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('account_id')->index();
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->string('email');
$table->string('role', 20)->default('member');
$table->string('status', 20)->default('invited');
$table->string('token', 64)->nullable();
$table->timestamp('accepted_at')->nullable();
$table->timestamps();
$table->unique(['account_id', 'email']);
});
}
public function down(): void
{
Schema::dropIfExists('qr_team_members');
}
};
@@ -0,0 +1,27 @@
<?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('qr_settings', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
$table->string('notify_email')->nullable();
$table->boolean('product_updates')->default(true);
$table->boolean('low_balance_alerts')->default(true);
$table->string('default_type', 32)->nullable();
$table->json('default_style')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('qr_settings');
}
};
@@ -0,0 +1,39 @@
<?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('qr_sale_orders', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('pay_order_id')->nullable();
$table->foreignId('qr_code_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('customer_name', 120)->nullable();
$table->string('customer_email', 200)->nullable();
$table->string('customer_phone', 30)->nullable();
$table->json('items');
$table->decimal('amount_ghs', 10, 2);
$table->decimal('platform_fee_ghs', 10, 2)->nullable();
$table->decimal('merchant_amount_ghs', 10, 2)->nullable();
$table->string('status', 20)->default('pending');
$table->string('fulfillment_status', 30)->default('new');
$table->string('payment_reference', 100)->nullable()->unique();
$table->timestamp('paid_at')->nullable();
$table->json('metadata')->nullable();
$table->timestamps();
$table->index(['qr_code_id', 'created_at']);
$table->index(['user_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('qr_sale_orders');
}
};
@@ -0,0 +1,42 @@
<?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('qr_bookings', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('pay_order_id')->nullable();
$table->foreignId('qr_code_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('customer_name', 120);
$table->string('customer_email', 200)->nullable();
$table->string('customer_phone', 30)->nullable();
$table->string('service_name', 160);
$table->unsignedSmallInteger('duration_minutes')->default(30);
$table->timestamp('starts_at');
$table->timestamp('ends_at');
$table->decimal('amount_ghs', 10, 2)->default(0);
$table->decimal('platform_fee_ghs', 10, 2)->nullable();
$table->decimal('merchant_amount_ghs', 10, 2)->nullable();
$table->string('status', 20)->default('pending');
$table->string('fulfillment_status', 30)->default('new');
$table->string('payment_reference', 100)->nullable()->unique();
$table->timestamp('paid_at')->nullable();
$table->json('metadata')->nullable();
$table->timestamps();
$table->index(['qr_code_id', 'starts_at']);
$table->index(['user_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('qr_bookings');
}
};
@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
DB::table('qr_codes')->where('type', 'book')->update(['type' => 'booking']);
}
public function down(): void
{
DB::table('qr_codes')->where('type', 'booking')->update(['type' => 'book']);
}
};
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Database\Seeders\HostingProductSeeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call([
HostingProductSeeder::class,
]);
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace Database\Seeders;
use App\Models\HostingNode;
use Illuminate\Database\Seeder;
class HostingNodeSeeder extends Seeder
{
public function run(): void
{
HostingNode::firstOrCreate(
['provider' => 'local', 'ip_address' => '127.0.0.1'],
[
'name' => 'Primary Server',
'hostname' => gethostname() ?: 'localhost',
'ip_address' => '127.0.0.1',
'ipv6_address' => '::1',
'type' => 'shared',
'segment' => 'general',
'provider' => 'local',
'cpu_cores' => 4,
'ram_mb' => 8192,
'disk_gb' => 150,
'oversell_ratio' => 3,
'bandwidth_tb' => 10,
'max_accounts' => 100,
'current_accounts' => 0,
'status' => 'active',
'ssh_port' => 22,
'features' => ['php', 'mysql', 'nginx', 'ssl'],
'installed_software' => [
'php' => ['8.1', '8.2', '8.3'],
'mysql' => '8.0',
'nginx' => '1.24',
],
]
);
}
}