migrate to gtea from bistbucket

This commit is contained in:
2026-03-15 17:08:23 +07:00
commit 129ca2260c
3716 changed files with 566316 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Modules\Authentication\Models\Restaurant;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('otp_verifications', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Restaurant::class)->constrained('restaurants')->cascadeOnDelete();
$table->string('phone');
$table->string('otp')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('otp_verifications');
}
};

View File

@@ -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('reviews', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('restaurant_id')->nullable();
$table->foreignId('customer_id')->constrained()->cascadeOnDelete();
$table->foreignId('food_item_id')->constrained()->cascadeOnDelete();
$table->tinyInteger('rating')->unsigned()->default(5);
$table->text('comment')->nullable();
// moderation & visibility
$table->boolean('is_approved')->default(false);
$table->boolean('is_active')->default(true);
// future analytics
$table->unsignedInteger('likes_count')->default(0);
$table->unsignedInteger('reported_count')->default(0);
$table->smallInteger('status')->default(1)->comment('1=Active, 2=InActive');
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('reviews');
}
};

View File

@@ -0,0 +1,28 @@
<?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('review_images', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('restaurant_id')->nullable();
$table->foreignId('review_id')->constrained('reviews')->cascadeOnDelete();
$table->string('image_path');
$table->tinyInteger('position')->default(1);
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('review_images');
}
};

View File

@@ -0,0 +1,137 @@
<?php
namespace Modules\Customer\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Modules\Booking\Database\Seeders\BookingTableSeeder;
use Modules\Restaurant\Models\Customer;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
class CustomerDatabaseSeeder extends Seeder
{
private $customerPermissions = [
'dashboard',
'customer',
'profile_index',
'profile_edit',
'menu_types_index',
'menu_sections_index',
'menu_categories_index',
'food_categories_index',
'food_items_index',
'food_variants_index',
'food_variant_ingredients_index',
'tables_index',
'reservations_index',
'reservations_create',
'reservation_unavailability_index',
'my_orders_index',
'my_orders_create',
'my_orders_edit',
'my_orders_delete',
'my_orders_show',
];
public function run(): void
{
/** ----------------------------------------------------------------
* 1) Create Permissions for Customer Guard
* ----------------------------------------------------------------*/
foreach ($this->customerPermissions as $permissionName) {
Permission::updateOrCreate([
'name' => $permissionName,
'guard_name' => 'customer',
]);
}
/** ----------------------------------------------------------------
* 2) Create Customer Role
* ----------------------------------------------------------------*/
$customerRole = Role::updateOrCreate([
'name' => 'Customer',
'guard_name' => 'customer',
'restaurant_id' => null,
]);
$customerRole->syncPermissions($this->customerPermissions);
/** ----------------------------------------------------------------
* 3) Walk-in Customer
* ----------------------------------------------------------------*/
Customer::updateOrCreate([
'customer_code' => 'CUST-WALKIN',
], [
'restaurant_id' => 1,
'name' => 'Walk-in',
'phone' => '00123456789',
'address' => 'Counter',
'status' => 1,
]);
/** ----------------------------------------------------------------
* 4) Demo Customers
* ----------------------------------------------------------------*/
for ($i = 1; $i <= 10; $i++) {
$customer = Customer::updateOrCreate(
['email' => "customer{$i}@example.com"],
[
'restaurant_id' => 1,
'customer_code' => 'CUST-'.strtoupper(Str::random(6)),
'name' => "Customer {$i}",
'email_verified_at' => now(),
'phone' => "013000000{$i}",
'password' => Hash::make('password123'),
'platform' => 'WEB',
'address' => 'Dhaka, Bangladesh',
'status' => 1,
]
);
// Assign role safely
$customer->assignRole($customerRole); // ✅ pass name only
}
$this->command->info('✅ Seeded 1 Walk-in + 10 demo customers successfully.');
/** ----------------------------------------------------------------
* 5) OAuth Clients for Users and Customers
* ----------------------------------------------------------------*/
$this->createOAuthClient('users', 'User Personal Access Client');
$this->createOAuthClient('customers', 'Customer Personal Access Client');
// 6) Booking Module Seeders
$this->call([
BookingTableSeeder::class,
]);
}
private function createOAuthClient(string $provider, string $name): void
{
$clientId = (string) Str::uuid();
$clientSecret = Str::random(40);
DB::table('oauth_clients')->updateOrInsert(
['provider' => $provider],
[
'id' => $clientId,
'owner_type' => null,
'owner_id' => null,
'name' => $name,
'secret' => Hash::make($clientSecret),
'provider' => $provider,
'redirect_uris' => '[]',
'grant_types' => '["personal_access"]',
'revoked' => 0,
'created_at' => now(),
'updated_at' => now(),
]
);
$this->command->info("🔐 OAuth $provider Client ID: $clientId");
$this->command->info("🔐 OAuth $provider Secret: $clientSecret");
}
}