Initial commit - Tabeley Backend

This commit is contained in:
Zaki-Malla
2026-02-17 19:33:49 +03:00
commit 3c885722f3
109 changed files with 14520 additions and 0 deletions
@@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$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,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,29 @@
<?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('users', function (Blueprint $table) {
// نحذف name الافتراضي
$table->dropColumn('name');
// نضيف الحقول تبع مشروعنا
$table->string('first_name');
$table->string('last_name');
$table->string('phone')->unique();
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('name');
$table->dropColumn(['first_name', 'last_name', 'phone']);
});
}
};
@@ -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::create('roles', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('roles');
}
};
@@ -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('user_roles', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('role_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->unique(['user_id', 'role_id']);
});
}
public function down(): void
{
Schema::dropIfExists('user_roles');
}
};
@@ -0,0 +1,26 @@
<?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('venues', function (Blueprint $table) {
$table->id();
$table->foreignId('vendor_id')->constrained('users')->cascadeOnDelete();
$table->string('name');
$table->text('description')->nullable();
$table->string('address')->nullable();
$table->string('phone')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('venues');
}
};
@@ -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('venues', function (Blueprint $table) {
$table->string('type')->default('restaurant');
});
}
public function down(): void
{
Schema::table('venues', function (Blueprint $table) {
$table->dropColumn('type');
});
}
};
@@ -0,0 +1,24 @@
<?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('venues', function (Blueprint $table) {
$table->string('address_text')->nullable();
$table->decimal('lat', 10, 7)->nullable();
$table->decimal('lng', 10, 7)->nullable();
});
}
public function down(): void
{
Schema::table('venues', function (Blueprint $table) {
$table->dropColumn(['address_text', 'lat', 'lng']);
});
}
};
@@ -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('venues', function (Blueprint $table) {
$table->boolean('is_active')->default(true);
});
}
public function down(): void
{
Schema::table('venues', function (Blueprint $table) {
$table->dropColumn('is_active');
});
}
};
@@ -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('reservations', function (Blueprint $table) {
$table->id();
$table->foreignId('customer_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('venue_id')->constrained('venues')->cascadeOnDelete();
$table->date('reservation_date');
$table->time('reservation_time');
$table->unsignedSmallInteger('party_size');
$table->string('status')->default('pending');
$table->string('rejection_reason')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('reservations');
}
};
@@ -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('reservations', function (Blueprint $table) {
$table->string('code', 8)->unique();
});
}
public function down(): void
{
Schema::table('reservations', function (Blueprint $table) {
$table->dropColumn('code');
});
}
};
@@ -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('reservation_status_histories', function (Blueprint $table) {
$table->id();
$table->foreignId('reservation_id')->constrained('reservations')->cascadeOnDelete();
$table->string('old_status')->nullable();
$table->string('new_status');
$table->foreignId('changed_by_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('created_at')->useCurrent();
});
}
public function down(): void
{
Schema::dropIfExists('reservation_status_histories');
}
};
@@ -0,0 +1,24 @@
<?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('users', function (Blueprint $table) {
$table->unsignedSmallInteger('strike_count')->default(0);
$table->timestamp('blocked_until')->nullable();
$table->boolean('blocked_permanent')->default(false);
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['strike_count', 'blocked_until', 'blocked_permanent']);
});
}
};
@@ -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('notifications', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->enum('type', ['reservation_approved', 'reservation_rejected', 'reservation_reminder', 'general']);
$table->string('title');
$table->text('body');
$table->json('data_json')->nullable();
$table->boolean('is_read')->default(false);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -0,0 +1,26 @@
<?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('reservation_reminders', function (Blueprint $table) {
$table->id();
$table->foreignId('reservation_id')->constrained('reservations')->cascadeOnDelete();
$table->timestamp('send_at');
$table->timestamp('sent_at')->nullable();
$table->timestamps();
$table->unique('reservation_id');
});
}
public function down(): void
{
Schema::dropIfExists('reservation_reminders');
}
};
@@ -0,0 +1,26 @@
<?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('pricing_rules', function (Blueprint $table) {
$table->id();
$table->enum('scope', ['global', 'type', 'venue']);
$table->string('venue_type')->nullable();
$table->foreignId('venue_id')->nullable()->constrained('venues')->nullOnDelete();
$table->decimal('price_per_person', 10, 2);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('pricing_rules');
}
};
@@ -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('reservation_fees', function (Blueprint $table) {
$table->id();
$table->foreignId('reservation_id')->constrained('reservations')->cascadeOnDelete();
$table->foreignId('pricing_rule_id')->nullable()->constrained('pricing_rules')->nullOnDelete();
$table->decimal('price_per_person', 10, 2);
$table->unsignedSmallInteger('party_size');
$table->decimal('total_amount', 10, 2);
$table->string('currency', 3)->default('USD');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('reservation_fees');
}
};
@@ -0,0 +1,24 @@
<?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('seating_areas', function (Blueprint $table) {
$table->id();
$table->foreignId('venue_id')->constrained('venues')->cascadeOnDelete();
$table->string('name');
$table->string('description')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('seating_areas');
}
};
@@ -0,0 +1,26 @@
<?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('venue_tables', function (Blueprint $table) {
$table->id();
$table->foreignId('venue_id')->constrained('venues')->cascadeOnDelete();
$table->foreignId('seating_area_id')->nullable()->constrained('seating_areas')->nullOnDelete();
$table->string('name');
$table->unsignedSmallInteger('capacity');
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('venue_tables');
}
};
@@ -0,0 +1,24 @@
<?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('reservation_table_assignments', function (Blueprint $table) {
$table->id();
$table->foreignId('reservation_id')->constrained('reservations')->cascadeOnDelete();
$table->foreignId('venue_table_id')->constrained('venue_tables')->cascadeOnDelete();
$table->timestamp('assigned_at')->useCurrent();
$table->unique('reservation_id');
});
}
public function down(): void
{
Schema::dropIfExists('reservation_table_assignments');
}
};
@@ -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('venues', function (Blueprint $table) {
$table->json('amenities')->nullable();
});
}
public function down(): void
{
Schema::table('venues', function (Blueprint $table) {
$table->dropColumn('amenities');
});
}
};
@@ -0,0 +1,23 @@
<?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('venues', function (Blueprint $table) {
$table->json('image_urls')->nullable();
$table->json('offers')->nullable();
});
}
public function down(): void
{
Schema::table('venues', function (Blueprint $table) {
$table->dropColumn(['image_urls', 'offers']);
});
}
};
@@ -0,0 +1,23 @@
<?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('user_feedback', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->text('message');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('user_feedback');
}
};