classify admin
This commit is contained in:
@@ -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->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
42
database/migrations/2023_03_18_033231_create_users_table.php
Normal file
42
database/migrations/2023_03_18_033231_create_users_table.php
Normal file
@@ -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 {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::create('users', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('mobile')->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('profile')->nullable();
|
||||
$table->string('type')->comment('email/google/mobile');
|
||||
$table->string('password');
|
||||
$table->string('fcm_id');
|
||||
$table->boolean('notification')->default(0);
|
||||
$table->string('firebase_id')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unique(['firebase_id', 'type']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
|
||||
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
276
database/migrations/2024_02_20_051429_v1.0.0.php
Normal file
276
database/migrations/2024_02_20_051429_v1.0.0.php
Normal file
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() {
|
||||
Schema::create('custom_fields', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->string('image');
|
||||
$table->boolean('required');
|
||||
$table->text('values')->nullable();
|
||||
$table->integer('min_length')->nullable();
|
||||
$table->integer('max_length')->nullable();
|
||||
$table->boolean('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('categories', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('sequence')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('image');
|
||||
$table->foreignId('parent_category_id')->nullable()->references('id')->on('categories')->onDelete('restrict');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('custom_field_categories', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->foreignId('custom_field_id')->references('id')->on('custom_fields')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('items', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->text('description');
|
||||
$table->double('price');
|
||||
$table->string('image');
|
||||
$table->double('latitude');
|
||||
$table->double('longitude');
|
||||
$table->text('address');
|
||||
$table->string('contact');
|
||||
$table->boolean('show_only_to_premium');
|
||||
$table->enum('status', ['review', 'approved', 'rejected', 'sold out', 'featured']);
|
||||
$table->string('video_link')->nullable();
|
||||
$table->string('city');
|
||||
$table->string('state');
|
||||
$table->string('country');
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('category_id')->references('id')->on('categories')->onDelete('restrict');
|
||||
$table->string('all_category_ids', 512)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('item_custom_field_values', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->foreignId('custom_field_id')->references('id')->on('custom_fields')->onDelete('cascade');
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['item_id', 'custom_field_id']);
|
||||
});
|
||||
|
||||
Schema::create('languages', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code');
|
||||
$table->string('name');
|
||||
$table->string('app_file');
|
||||
$table->string('panel_file');
|
||||
$table->boolean('rtl');
|
||||
$table->string('image', 512)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('item_images', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image');
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('settings', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->enum('type', ['string', 'file'])->default('string');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('packages', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->integer('price');
|
||||
$table->integer('discount_price')->default(0);
|
||||
$table->string('duration');
|
||||
$table->string('item_limit');
|
||||
$table->string('type');
|
||||
$table->string('icon');
|
||||
$table->longText('description');
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->string('ios_product_id', 512)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('sliders', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image');
|
||||
$table->string('sequence');
|
||||
$table->string('third_party_link')->nullable();
|
||||
$table->integer('item_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('report_reasons', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->longText('reason');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('user_reports', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('report_reason_id')->nullable()->references('id')->on('report_reasons')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
/*TODO : why there are 2 column other_message & reason*/
|
||||
$table->longText('other_message')->nullable();
|
||||
$table->longText('reason');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('user_purchased_packages', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('package_id')->references('id')->on('packages')->onDelete('cascade');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date')->nullable();
|
||||
$table->integer('total_limit')->nullable();
|
||||
$table->integer('used_limit')->default(0);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('feature_sections', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->integer('sequence');
|
||||
$table->string('filter');
|
||||
$table->string('value')->nullable();
|
||||
$table->string('style');
|
||||
$table->integer('min_price')->nullable();
|
||||
$table->integer('max_price')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('notifications', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('title');
|
||||
$table->text('message');
|
||||
$table->text('image');
|
||||
$table->foreignId('item_id')->nullable()->references('id')->on('items')->onDelete('cascade');
|
||||
$table->enum('send_to', ['all', 'selected']);
|
||||
$table->string('user_id', 512)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('featured_items', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('start_date');
|
||||
$table->date('end_date')->nullable();
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->foreignId('package_id')->references('id')->on('packages')->onDelete('cascade');
|
||||
$table->foreignId('user_purchased_package_id')->references('id')->on('user_purchased_packages')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
$table->unique(['item_id', 'package_id']);
|
||||
});
|
||||
|
||||
Schema::create('favourites', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('payment_configurations', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('payment_method');
|
||||
$table->string('api_key');
|
||||
$table->string('secret_key');
|
||||
$table->string('webhook_secret_key');
|
||||
$table->string('currency_code', 128)->nullable();
|
||||
$table->boolean('status')->comment('0 - Disabled, 1 - Enabled')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('payment_transactions', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->double('amount', 8, 2);
|
||||
$table->string('payment_gateway', 128);
|
||||
$table->string('order_id')->comment('order_id / payment_intent_id')->nullable();
|
||||
$table->string('payment_id')->nullable();
|
||||
$table->string('payment_signature')->nullable();
|
||||
$table->enum('payment_status', ['failed', 'succeed', 'pending']);
|
||||
$table->timestamps();
|
||||
$table->unique(['payment_gateway', 'order_id']);
|
||||
});
|
||||
|
||||
|
||||
Schema::table('roles', static function (Blueprint $table) {
|
||||
$table->boolean('custom_role')->after('guard_name')->default(0);
|
||||
});
|
||||
|
||||
Schema::create('item_offers', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('seller_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('buyer_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->float('amount');
|
||||
$table->timestamps();
|
||||
/*Seller id is redundant here to adding it to the unique constraint will be the wastage*/
|
||||
$table->unique(['buyer_id', 'item_id']);
|
||||
});
|
||||
|
||||
Schema::create('chats', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('sender_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('item_offer_id')->references('id')->on('item_offers')->onDelete('cascade');
|
||||
$table->string('message');
|
||||
$table->string('file')->nullable();
|
||||
$table->string('audio')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() {
|
||||
Schema::disableForeignKeyConstraints();
|
||||
Schema::dropIfExists('custom_fields');
|
||||
Schema::dropIfExists('custom_field_categories');
|
||||
Schema::dropIfExists('item_custom_field_values');
|
||||
Schema::dropIfExists('languages');
|
||||
Schema::dropIfExists('categories');
|
||||
Schema::dropIfExists('items');
|
||||
Schema::dropIfExists('item_images');
|
||||
Schema::dropIfExists('settings');
|
||||
Schema::dropIfExists('packages');
|
||||
Schema::dropIfExists('sliders');
|
||||
Schema::dropIfExists('report_reasons');
|
||||
Schema::dropIfExists('user_reports');
|
||||
Schema::dropIfExists('user_purchased_packages');
|
||||
Schema::dropIfExists('feature_sections');
|
||||
Schema::dropIfExists('notification');
|
||||
Schema::dropIfExists('advertisements');
|
||||
Schema::dropIfExists('favourites');
|
||||
Schema::dropIfExists('payment_configurations');
|
||||
}
|
||||
};
|
||||
44
database/migrations/2024_04_09_095310_v1.0.1.php
Normal file
44
database/migrations/2024_04_09_095310_v1.0.1.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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 {
|
||||
|
||||
if (!Schema::hasColumn('items', 'clicks')) {
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->integer('clicks')->after('all_category_ids');
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
$table->string('name_in_english', 32)->after('name');
|
||||
});
|
||||
|
||||
Schema::table('chats', static function (Blueprint $table) {
|
||||
$table->string('message')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->dropColumn('clicks');
|
||||
});
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
$table->dropColumn('name_in_english');
|
||||
});
|
||||
|
||||
Schema::table('chats', static function (Blueprint $table) {
|
||||
$table->string('message')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
113
database/migrations/2024_04_25_075053_v1.0.2.php
Normal file
113
database/migrations/2024_04_25_075053_v1.0.2.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Package;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void {
|
||||
Setting::insert([
|
||||
['name' => 'banner_ad_id_android', 'value' => ''],
|
||||
['name' => 'banner_ad_id_ios', 'value' => ''],
|
||||
['name' => 'banner_ad_status', 'value' => 1],
|
||||
|
||||
['name' => 'interstitial_ad_id_android', 'value' => ''],
|
||||
['name' => 'interstitial_ad_id_ios', 'value' => ''],
|
||||
['name' => 'interstitial_ad_status', 'value' => 1],
|
||||
]);
|
||||
|
||||
Schema::table('packages', static function (Blueprint $table) {
|
||||
/*Rename the column*/
|
||||
$table->renameColumn('price', 'final_price');
|
||||
$table->renameColumn('discount_price', 'price');
|
||||
|
||||
/*Add new column*/
|
||||
$table->float('discount_in_percentage')->after('price')->default(0);
|
||||
});
|
||||
|
||||
/*This code is added separately because datatype was not changing when running in the code snippet*/
|
||||
Schema::table('packages', static function (Blueprint $table) {
|
||||
$table->float('price')->after('name')->change();
|
||||
$table->float('final_price')->after('discount_in_percentage')->change();
|
||||
});
|
||||
|
||||
foreach (Package::whereNot('final_price', 0)->get() as $package) {
|
||||
$package->price = $package->final_price;
|
||||
$package->save();
|
||||
}
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->string('state')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::create('block_users', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('restrict');
|
||||
$table->foreignId('blocked_user_id')->references('id')->on('users')->onDelete('restrict');
|
||||
$table->unique(['user_id', 'blocked_user_id']);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('tips', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('description', 512);
|
||||
$table->integer('sequence');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('tip_translations', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tip_id')->references('id')->on('tips')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->references('id')->on('languages')->onDelete('cascade');
|
||||
$table->string('description', 512);
|
||||
$table->timestamps();
|
||||
$table->unique(['tip_id', 'language_id']);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {
|
||||
Setting::whereIn('name', [
|
||||
'banner_ad_id_android',
|
||||
'banner_ad_id_ios',
|
||||
'banner_ad_status',
|
||||
'interstitial_ad_id_android',
|
||||
'interstitial_ad_id_ios',
|
||||
'interstitial_ad_status',
|
||||
])->delete();
|
||||
|
||||
Schema::table('packages', static function (Blueprint $table) {
|
||||
/*Rename the column*/
|
||||
$table->renameColumn('price', 'discount_price');
|
||||
$table->renameColumn('final_price', 'price');
|
||||
|
||||
/*Add new column*/
|
||||
$table->dropColumn('discount_in_percentage');
|
||||
});
|
||||
|
||||
/*This code is added separately because datatype was not changing when running in the code snippet*/
|
||||
Schema::table('packages', static function (Blueprint $table) {
|
||||
/*Change Datatype of old columns*/
|
||||
$table->integer('price')->change();
|
||||
$table->integer('discount_price')->change();
|
||||
});
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->string('state')->nullable(false)->change();
|
||||
});
|
||||
|
||||
Schema::dropIfExists('block_users');
|
||||
Schema::dropIfExists('tips');
|
||||
Schema::dropIfExists('tip_translations');
|
||||
|
||||
}
|
||||
};
|
||||
239
database/migrations/2024_05_31_080315_v1.1.0.php
Normal file
239
database/migrations/2024_05_31_080315_v1.1.0.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?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 {
|
||||
if (!Schema::hasTable('blogs')) {
|
||||
Schema::create('blogs', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 512);
|
||||
$table->string('slug', 512);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('image', 512);
|
||||
$table->string('tags')->nullable();
|
||||
$table->integer('views')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('category_translations')) {
|
||||
Schema::create('category_translations', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->references('id')->on('languages')->onDelete('cascade');
|
||||
$table->string('name', 125);
|
||||
$table->timestamps();
|
||||
$table->unique(['category_id', 'language_id']);
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('countries')) {
|
||||
Schema::create('countries', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->char('iso3', 3)->nullable();
|
||||
$table->char('numeric_code', 3)->nullable();
|
||||
$table->char('iso2', 2)->nullable();
|
||||
$table->string('phonecode', 255)->nullable();
|
||||
$table->string('capital', 255)->nullable();
|
||||
$table->string('currency', 255)->nullable();
|
||||
$table->string('currency_name', 255)->nullable();
|
||||
$table->string('currency_symbol', 255)->nullable();
|
||||
$table->string('tld', 255)->nullable();
|
||||
$table->string('native', 255)->nullable();
|
||||
$table->string('region', 255)->nullable();
|
||||
$table->integer('region_id')->nullable();
|
||||
$table->string('subregion', 255)->nullable();
|
||||
$table->integer('subregion_id')->nullable();
|
||||
$table->string('nationality', 255)->nullable();
|
||||
$table->text('timezones')->nullable();
|
||||
$table->text('translations')->nullable();
|
||||
$table->decimal('latitude')->nullable();
|
||||
$table->decimal('longitude')->nullable();
|
||||
$table->string('emoji', 191)->nullable();
|
||||
$table->string('emojiU', 191)->nullable();
|
||||
$table->boolean('flag')->nullable();
|
||||
$table->string('wikiDataId', 255)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('states')) {
|
||||
Schema::create('states', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255);
|
||||
$table->foreignId('country_id')->references('id')->on('countries')->onDelete('cascade');
|
||||
$table->char('state_code', 2);
|
||||
$table->string('fips_code', 255)->nullable();
|
||||
$table->string('iso2', 255)->nullable();
|
||||
$table->string('type', 191)->nullable();
|
||||
$table->decimal('latitude')->nullable();
|
||||
$table->decimal('longitude')->nullable();
|
||||
$table->boolean('flag')->nullable();
|
||||
$table->string('wikiDataId', 255)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('cities')) {
|
||||
Schema::create('cities', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255);
|
||||
$table->foreignId('state_id')->references('id')->on('states')->onDelete('cascade');
|
||||
$table->string('state_code', 255);
|
||||
$table->foreignId('country_id')->references('id')->on('countries')->onDelete('cascade');
|
||||
$table->char('country_code', 2);
|
||||
$table->decimal('latitude')->nullable();
|
||||
$table->decimal('longitude')->nullable();
|
||||
$table->boolean('flag')->nullable();
|
||||
$table->string('wikiDataId', 255)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('faqs')) {
|
||||
Schema::create('faqs', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('question');
|
||||
$table->string('answer');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('social_logins')) {
|
||||
Schema::create('social_logins', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->string('firebase_id', 512);
|
||||
$table->enum('type', ['google', 'email', 'phone']);
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'type']);
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('areas')) {
|
||||
Schema::create('areas', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255);
|
||||
$table->foreignId('city_id')->references('id')->on('cities')->onDelete('cascade');
|
||||
$table->foreignId('state_id')->references('id')->on('states')->onDelete('cascade');
|
||||
$table->string('state_code', 255)->nullable();
|
||||
$table->foreignId('country_id')->references('id')->on('countries')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Schema::table('sliders', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('sliders', 'model_id') && !Schema::hasColumn('sliders', 'model_type')) {
|
||||
$table->nullableMorphs('model');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Schema::table('user_purchased_packages', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('user_purchased_packages', 'payment_transactions_id')) {
|
||||
$table->foreignId('payment_transactions_id')->after('used_limit')->nullable()->references('id')->on('payment_transactions')->onDelete('cascade');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('users', 'country_code')) {
|
||||
$table->string('country_code')->nullable();
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('payment_transactions', static function (Blueprint $table) {
|
||||
if (Schema::hasColumn('payment_transactions', 'payment_id')) {
|
||||
$table->dropColumn('payment_id');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('payment_transactions', 'payment_signature')) {
|
||||
$table->dropColumn('payment_signature');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('items', 'area_id')) {
|
||||
$table->foreignId('area_id')->after('country')->nullable()->references('id')->on('areas')->onDelete('restrict');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('items', 'slug')) {
|
||||
$table->string('slug', 512)->after('name');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('items', 'rejected_reason')) {
|
||||
$table->string('rejected_reason')->after('status')->nullable();
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('categories', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('categories', 'slug')) {
|
||||
$table->string('slug', 512);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('languages', 'slug')) {
|
||||
$table->string('slug', 512)->after('name');
|
||||
}
|
||||
if (!Schema::hasColumn('languages', 'web_file')) {
|
||||
$table->string('web_file')->after('panel_file');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public
|
||||
function down(): void {
|
||||
Schema::dropIfExists('blogs');
|
||||
Schema::dropIfExists('category_translations');
|
||||
Schema::dropIfExists('faqs');
|
||||
Schema::dropIfExists('social_logins');
|
||||
Schema::dropIfExists('areas');
|
||||
|
||||
Schema::table('sliders', static function (Blueprint $table) {
|
||||
$table->dropMorphs('model');
|
||||
});
|
||||
|
||||
Schema::table('user_purchased_packages', static function (Blueprint $table) {
|
||||
$table->dropColumn('payment_transactions_id');
|
||||
});
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->dropColumn('country_code');
|
||||
});
|
||||
|
||||
Schema::table('payment_transactions', static function (Blueprint $table) {
|
||||
$table->string('payment_id')->nullable();
|
||||
$table->string('payment_signature')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
$table->dropColumn('web_file');
|
||||
});
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->dropColumn('area_id');
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
|
||||
Schema::table('categories', static function (Blueprint $table) {
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
$table->dropColumn('web_file');
|
||||
});
|
||||
}
|
||||
};
|
||||
117
database/migrations/2024_05_31_080315_v1.1.0_data_changes.php
Normal file
117
database/migrations/2024_05_31_080315_v1.1.0_data_changes.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Item;
|
||||
use App\Models\Slider;
|
||||
use App\Models\SocialLogin;
|
||||
use App\Models\User;
|
||||
use App\Services\HelperService;
|
||||
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 {
|
||||
/* 1. Slider Changes */
|
||||
|
||||
if (Schema::hasColumn('sliders', 'item_id')) {
|
||||
foreach (Slider::whereNot('item_id', 0)->get() as $slider) {
|
||||
$item = Item::find($slider->item_id);
|
||||
if ($item) {
|
||||
$slider->model()->associate($item);
|
||||
$slider->save();
|
||||
} else {
|
||||
$slider->delete();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::disableForeignKeyConstraints();
|
||||
Schema::table('sliders', static function (Blueprint $table) {
|
||||
$table->dropColumn('item_id');
|
||||
});
|
||||
Schema::enableForeignKeyConstraints();
|
||||
} catch (Exception $e) {
|
||||
// Foreign key doesn't exist, so just catch the exception and move on.
|
||||
}
|
||||
}
|
||||
/* 2. User Changes */
|
||||
$socialLogin = [];
|
||||
$userRole = (new Spatie\Permission\Models\Role)->where('name', 'User')->count();
|
||||
if ($userRole > 0) {
|
||||
foreach (User::role('User')->whereNotNull('firebase_id')->get() as $user) {
|
||||
$socialLogin[] = [
|
||||
'firebase_id' => $user->firebase_id,
|
||||
'type' => $user->type,
|
||||
'user_id' => $user->id
|
||||
];
|
||||
}
|
||||
if (count($socialLogin) > 0) {
|
||||
SocialLogin::upsert($socialLogin, ['user_id', 'type'], ['firebase_id']);
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->string('firebase_id')->comment('remove in next update')->nullable()->change();
|
||||
$table->string('type')->comment('remove in next update')->nullable()->change();
|
||||
});
|
||||
|
||||
|
||||
/* 3.Slug Generation */
|
||||
|
||||
Category::chunk(100, static function ($categories) {
|
||||
$tempCategories = [];
|
||||
foreach ($categories as $category) {
|
||||
$tempCategories[] = [
|
||||
'id' => $category->id,
|
||||
'slug' => HelperService::generateUniqueSlug(new Category(), $category->name, $category->id)
|
||||
];
|
||||
}
|
||||
|
||||
if (count($tempCategories) > 0) {
|
||||
Category::upsert($tempCategories, ['id'], ['slug']);
|
||||
}
|
||||
});
|
||||
|
||||
Item::withTrashed()->chunk(100, static function ($items) {
|
||||
$tempItems = [];
|
||||
foreach ($items as $item) {
|
||||
$tempItems[] = [
|
||||
'id' => $item->id,
|
||||
'slug' => HelperService::generateUniqueSlug(new Item(), $item->name, $item->id),
|
||||
'status' => $item->status == "featured" ? "approved" : $item->status
|
||||
];
|
||||
}
|
||||
|
||||
if (count($tempItems) > 0) {
|
||||
Item::upsert($tempItems, ['id'], ['slug', 'status']);
|
||||
}
|
||||
});
|
||||
Schema::useNativeSchemaOperationsIfPossible();
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
//Featured status removed
|
||||
$table->enum('status', ['review', 'approved', 'rejected', 'sold out'])->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {
|
||||
Schema::table('sliders', static function (Blueprint $table) {
|
||||
$table->foreignId('item_id')->nullable()->references('id')->on('items')->onDelete('cascade');
|
||||
});
|
||||
foreach (Slider::whereHasMorph('model', Item::class)->get() as $slider) {
|
||||
$slider->item_id = $slider->model_id;
|
||||
$slider->save();
|
||||
}
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->string('type')->comment('email/google/mobile')->nullable(false)->change();
|
||||
$table->string('firebase_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
149
database/migrations/2024_06_21_122400_v2.0.0.php
Normal file
149
database/migrations/2024_06_21_122400_v2.0.0.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Blog;
|
||||
use App\Models\Category;
|
||||
use App\Models\FeatureSection;
|
||||
use App\Models\Item;
|
||||
use App\Models\User;
|
||||
use App\Models\UserFcmToken;
|
||||
use App\Services\HelperService;
|
||||
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::table('feature_sections', static function (Blueprint $table) {
|
||||
$table->string('slug', 512)->after('title');
|
||||
});
|
||||
|
||||
FeatureSection::chunk(100, static function ($data) {
|
||||
foreach ($data as $featureSection) {
|
||||
$featureSection->update([
|
||||
'slug' => HelperService::generateUniqueSlug(new FeatureSection(), $featureSection->title, $featureSection->id)
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('feature_sections', static function (Blueprint $table) {
|
||||
$table->unique('slug');
|
||||
});
|
||||
|
||||
Blog::chunk(100, static function ($data) {
|
||||
foreach ($data as $blog) {
|
||||
$blog->update([
|
||||
'slug' => HelperService::generateUniqueSlug(new Blog(), $blog->title, $blog->id)
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Item::withTrashed()->chunk(100, static function ($items) {
|
||||
foreach ($items as $item) {
|
||||
$item->update([
|
||||
'slug' => HelperService::generateUniqueSlug(new Item(), $item->name, $item->id),
|
||||
]);
|
||||
}
|
||||
});
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->unique('slug');
|
||||
if (!Schema::hasColumn('items', 'rejected_reason')) {
|
||||
$table->string('rejected_reason')->after('status')->nullable();
|
||||
}
|
||||
});
|
||||
|
||||
Category::chunk(100, static function ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
$category->update([
|
||||
'slug' => HelperService::generateUniqueSlug(new Category(), $category->name, $category->id)
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('categories', static function (Blueprint $table) {
|
||||
$table->unique('slug');
|
||||
});
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
|
||||
Schema::useNativeSchemaOperationsIfPossible();
|
||||
Schema::table('social_logins', static function (Blueprint $table) {
|
||||
$table->enum('type', ['google', 'email', 'phone', 'apple'])->change();
|
||||
});
|
||||
|
||||
Schema::create('contact_us', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('subject');
|
||||
$table->text('message');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('user_fcm_tokens', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->string('fcm_token');
|
||||
$table->timestamps();
|
||||
$table->unique('fcm_token');
|
||||
});
|
||||
|
||||
$tokens = [];
|
||||
foreach (User::whereNotNull('fcm_id')->whereNot('fcm_id', '')->get() as $user) {
|
||||
$tokens[] = [
|
||||
'user_id' => $user->id,
|
||||
'fcm_token' => $user->fcm_id,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
];
|
||||
}
|
||||
if (count($tokens) > 0) {
|
||||
UserFcmToken::insertOrIgnore($tokens);
|
||||
}
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->string('fcm_id')->comment('remove this in next update')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {
|
||||
Schema::table('feature_sections', static function (Blueprint $table) {
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
|
||||
Schema::table('blogs', static function (Blueprint $table) {
|
||||
$table->dropUnique('blogs_slug_unique');
|
||||
});
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->dropUnique('slug');
|
||||
});
|
||||
|
||||
Schema::table('categories', static function (Blueprint $table) {
|
||||
$table->dropUnique('slug');
|
||||
});
|
||||
|
||||
Schema::table('languages', static function (Blueprint $table) {
|
||||
$table->string('slug')->after('name');
|
||||
});
|
||||
|
||||
Schema::useNativeSchemaOperationsIfPossible();
|
||||
Schema::table('social_logins', static function (Blueprint $table) {
|
||||
$table->enum('type', ['google', 'email', 'phone'])->change();
|
||||
});
|
||||
|
||||
Schema::dropIfExists('contact_us');
|
||||
Schema::dropIfExists('user_fcm_tokens');
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->string('fcm_id')->comment('')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
147
database/migrations/2024_07_03_061134_v2.1.0.php
Normal file
147
database/migrations/2024_07_03_061134_v2.1.0.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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::table('users', static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('users','show_personal_details')) {
|
||||
$table->boolean('show_personal_details')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('users','is_verified')) {
|
||||
$table->boolean('is_verified')->default(0);
|
||||
}
|
||||
});
|
||||
Schema::table('block_users', static function (Blueprint $table) {
|
||||
$table->dropForeign('block_users_user_id_foreign');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
||||
|
||||
$table->dropForeign('block_users_blocked_user_id_foreign');
|
||||
$table->foreign('blocked_user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
|
||||
Schema::table('cities', static function (Blueprint $table) {
|
||||
$table->unique(['name', 'state_id', 'country_id']);
|
||||
});
|
||||
|
||||
Schema::table('item_offers', static function (Blueprint $table) {
|
||||
$table->float('amount')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->foreignId('sold_to')->after('user_id')->nullable()->references('id')->on('users')->onDelete('cascade');
|
||||
$table->date('expiry_date')->after('all_category_ids')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('seller_ratings', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('seller_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('buyer_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->string('review')->nullable();
|
||||
$table->float('ratings');
|
||||
$table->timestamps();
|
||||
$table->unique(['item_id', 'buyer_id']);
|
||||
});
|
||||
|
||||
Schema::create('verification_fields', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->text('values')->nullable();
|
||||
$table->integer('min_length')->nullable();
|
||||
$table->integer('max_length')->nullable();
|
||||
$table->enum('status', ['review', 'approved', 'rejected', 'sold out', 'featured']);
|
||||
$table->boolean('is_required')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
Schema::create('verification_requests', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->enum('status', ['pending', 'approved', 'rejected', 'resubmitted']);
|
||||
$table->text('rejection_reason')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('verification_field_values', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('verification_field_id')->references('id')->on('verification_fields')->onDelete('cascade');
|
||||
$table->text('value')->nullable();
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->foreignId('verification_request_id')->references('id')->on('verification_requests')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'verification_field_id']);
|
||||
});
|
||||
|
||||
Schema::create('seo_settings', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('page')->nullable();
|
||||
$table->string('title')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->string('keywords')->nullable();
|
||||
$table->string('image', 512)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::table('feature_sections', static function (Blueprint $table) {
|
||||
$table->string('description')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('user_fcm_tokens', static function (Blueprint $table) {
|
||||
$table->enum('platform_type', ['Android', 'iOS'])->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->dropColumn('show_personal_details');
|
||||
});
|
||||
|
||||
Schema::table('cities', static function (Blueprint $table) {
|
||||
$table->dropColumn('name', 'state_id', 'country_id');
|
||||
});
|
||||
|
||||
Schema::table('item_offers', static function (Blueprint $table) {
|
||||
$table->float('amount')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('items', static function (Blueprint $table) {
|
||||
$table->dropColumn('sold_to');
|
||||
$table->dropColumn('expiry_date');
|
||||
});
|
||||
|
||||
Schema::table('users', static function (Blueprint $table) {
|
||||
$table->dropColumn('is_verified');
|
||||
});
|
||||
|
||||
Schema::table('verification_requests', static function (Blueprint $table) {
|
||||
$table->dropColumn('rejection_reason');
|
||||
});
|
||||
|
||||
Schema::table('feature_sections', static function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
|
||||
Schema::table('user_fcm_tokens', static function (Blueprint $table) {
|
||||
$table->dropColumn('platform_type');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('seller_ratings');
|
||||
Schema::dropIfExists('verification_fields');
|
||||
Schema::dropIfExists('verification_requests');
|
||||
Schema::dropIfExists('verification_field_values');
|
||||
Schema::dropIfExists('seo_settings');
|
||||
}
|
||||
};
|
||||
@@ -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::table('seller_ratings', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
$table->enum('report_status', ['reported','rejected','approved'])->nullable();
|
||||
$table->string('report_reason')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('seller_ratings', function (Blueprint $table) {
|
||||
$table->dropColumn('report_status');
|
||||
$table->dropColumn('report_reason');
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('seller_ratings', function (Blueprint $table) {
|
||||
$table->string('report_rejected_reason')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('seller_ratings', function (Blueprint $table) {
|
||||
$table->dropColumn('report_rejected_reason');
|
||||
});
|
||||
}
|
||||
};
|
||||
30
database/migrations/2024_11_15_071656_update_users_table.php
Normal file
30
database/migrations/2024_11_15_071656_update_users_table.php
Normal file
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('show_personal_details')->default(1)->change();
|
||||
$table->boolean('notification')->default(1)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('show_personal_details')->default(0);
|
||||
$table->boolean('notification')->default(0);
|
||||
});
|
||||
}
|
||||
};
|
||||
56
database/migrations/2024_12_23_054350_v2.3.0.php
Normal file
56
database/migrations/2024_12_23_054350_v2.3.0.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
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::table('users', function (Blueprint $table) {
|
||||
$table->boolean('auto_approve_item')->default(0)->after('is_verified');
|
||||
});
|
||||
Schema::table('chats', function (Blueprint $table) {
|
||||
$table->boolean('is_read')->nullable();
|
||||
});
|
||||
Schema::table('languages', function (Blueprint $table) {
|
||||
$table->string('country_code')->nullable();
|
||||
});
|
||||
User::chunk(100, static function ($users) {
|
||||
$tempUsers = [];
|
||||
foreach ($users as $user) {
|
||||
if ($user->is_verified == 1) {
|
||||
$tempUsers[] = [
|
||||
'id' => $user->id,
|
||||
'auto_approve_item' => 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
if (count($tempUsers) > 0) {
|
||||
User::upsert($tempUsers, ['id'], ['auto_approve_item']);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('auto_approve_item');
|
||||
});
|
||||
Schema::table('chats', function (Blueprint $table) {
|
||||
$table->dropColumn('is_read');
|
||||
});
|
||||
Schema::table('languages', function (Blueprint $table) {
|
||||
$table->dropColumn('country_code');
|
||||
});
|
||||
}
|
||||
};
|
||||
73
database/migrations/2025_02_07_081104_v.2.4.0.php
Normal file
73
database/migrations/2025_02_07_081104_v.2.4.0.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Item;
|
||||
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
|
||||
{
|
||||
DB::statement("ALTER TABLE items MODIFY COLUMN status ENUM(
|
||||
'review',
|
||||
'approved',
|
||||
'soft rejected',
|
||||
'permanent rejected',
|
||||
'sold out',
|
||||
'featured',
|
||||
'resubmitted'
|
||||
) NOT NULL");
|
||||
|
||||
Item::chunk(100, static function ($items) {
|
||||
$tempUsers = [];
|
||||
foreach ($items as $item) {
|
||||
if (!empty($item->rejected_reason) && empty($item->status)) {
|
||||
$tempUsers[] = [
|
||||
'id' => $item->id,
|
||||
'status' => 'permanent rejected',
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!empty($tempUsers)) {
|
||||
Item::upsert($tempUsers, ['id'], ['status']);
|
||||
}
|
||||
});
|
||||
Item::chunk(100, static function ($items) {
|
||||
$tempUsers = [];
|
||||
foreach ($items as $item) {
|
||||
if (empty($item->status)) {
|
||||
$tempUsers[] = [
|
||||
'id' => $item->id,
|
||||
'status' => 'permanent rejected',
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!empty($tempUsers)) {
|
||||
Item::upsert($tempUsers, ['id'], ['status']);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE items MODIFY COLUMN status ENUM(
|
||||
'review',
|
||||
'approved',
|
||||
'rejected',
|
||||
'sold out',
|
||||
'featured'
|
||||
) NOT NULL");
|
||||
|
||||
DB::table('items')
|
||||
->where('status', 'permanent rejected')
|
||||
->update(['status' => 'rejected']);
|
||||
}
|
||||
};
|
||||
99
database/migrations/2025_04_11_154517_v.2.5.0.php
Normal file
99
database/migrations/2025_04_11_154517_v.2.5.0.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE payment_transactions MODIFY COLUMN payment_status ENUM(
|
||||
'failed',
|
||||
'succeed',
|
||||
'pending',
|
||||
'under review',
|
||||
'rejected'
|
||||
) NOT NULL");
|
||||
Schema::table('payment_transactions', function (Blueprint $table) {
|
||||
$table->string('payment_receipt')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('areas', function (Blueprint $table) {
|
||||
$table->decimal('latitude', 10, 8)->nullable()->after('country_id');
|
||||
$table->decimal('longitude', 11, 8)->nullable()->after('latitude');
|
||||
});
|
||||
Schema::create('number_otps', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('number')->unique();
|
||||
$table->string('otp');
|
||||
$table->timestamp('expire_at')->nullable();
|
||||
$table->unsignedTinyInteger('attempts')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::table('faqs', function (Blueprint $table) {
|
||||
$table->longText('answer')->change();
|
||||
});
|
||||
$updates = [
|
||||
'item-listing-package' => 'advertisement-listing-package',
|
||||
'advertisement-package' => 'featured-advertisement-package',
|
||||
'item' => 'advertisement',
|
||||
];
|
||||
|
||||
Permission::chunk(100, function ($permissions) use ($updates) {
|
||||
$updatedPermissions = [];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
foreach ($updates as $oldPrefix => $newPrefix) {
|
||||
if (str_starts_with($permission->name, $oldPrefix . '-')) {
|
||||
$newName = str_replace($oldPrefix, $newPrefix, $permission->name);
|
||||
|
||||
// Prevent duplicate names
|
||||
if (!Permission::where('name', $newName)
|
||||
->where('guard_name', $permission->guard_name)
|
||||
->exists()) {
|
||||
$updatedPermissions[] = [
|
||||
'id' => $permission->id,
|
||||
'name' => $newName,
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($updatedPermissions)) {
|
||||
Permission::upsert($updatedPermissions, ['id'], ['name']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE payment_transactions MODIFY COLUMN payment_status ENUM(
|
||||
'failed',
|
||||
'succeed',
|
||||
'pending'
|
||||
) NOT NULL");
|
||||
Schema::table('payment_transactions', function (Blueprint $table) {
|
||||
$table->dropColumn('payment_receipt');
|
||||
});
|
||||
Schema::table('areas', function (Blueprint $table) {
|
||||
$table->dropColumn(['latitude', 'longitude']);
|
||||
});
|
||||
Schema::dropIfExists('number_otps');
|
||||
|
||||
Schema::table('faqs', function (Blueprint $table) {
|
||||
$table->string('answer')->change(); // revert back if needed
|
||||
});
|
||||
}
|
||||
};
|
||||
56
database/migrations/2025_06_11_122312_v.2.6.0.php
Normal file
56
database/migrations/2025_06_11_122312_v.2.6.0.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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('job_applications', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreignId('recruiter_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->string('full_name');
|
||||
$table->string('email');
|
||||
$table->string('mobile');
|
||||
$table->string('resume')->nullable();
|
||||
$table->enum('status', ['pending', 'accepted', 'rejected'])->default('pending');
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'item_id'], 'unique_user_item');
|
||||
});
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->double('price')->nullable()->change();
|
||||
$table->double('min_salary')->nullable()->after('price');
|
||||
$table->double('max_salary')->nullable()->after('min_salary');
|
||||
$table->boolean('is_edited_by_admin')->default(0);
|
||||
$table->string('admin_edit_reason')->nullable()->after('is_edited_by_admin');
|
||||
});
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->boolean('is_job_category')->default(0);
|
||||
$table->boolean('price_optional')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('job_applications');
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->double('price')->nullable(false)->change();
|
||||
$table->dropColumn(['min_salary', 'max_salary']);
|
||||
$table->dropColumn(['is_edited_by_admin', 'admin_edit_reason']);
|
||||
});
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->dropColumn('is_job_category');
|
||||
$table->dropColumn('price_optional');
|
||||
});
|
||||
}
|
||||
};
|
||||
254
database/migrations/2025_08_27_125732_v.2.7.0.php
Normal file
254
database/migrations/2025_08_27_125732_v.2.7.0.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?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::table('payment_configurations', function (Blueprint $table) {
|
||||
$table->string('additional_data_1')->nullable();
|
||||
$table->string('additional_data_2')->nullable();
|
||||
$table->string('payment_mode')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('item_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('item_id')->constrained('items')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained('languages')->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->text('rejected_reason')->nullable();
|
||||
$table->string('admin_edit_reason')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['item_id', 'language_id']);
|
||||
});
|
||||
|
||||
Schema::create('custom_fields_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('custom_field_id')->constrained('custom_fields')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained('languages')->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['custom_field_id', 'language_id']);
|
||||
});
|
||||
Schema::table('item_custom_field_values', function (Blueprint $table) {
|
||||
$table->foreignId('language_id')->nullable()->references('id')->on('languages')->onDelete('cascade');
|
||||
});
|
||||
Schema::table('item_custom_field_values', function (Blueprint $table) {
|
||||
$table->dropForeign(['item_id']);
|
||||
$table->dropForeign(['custom_field_id']);
|
||||
$table->dropUnique('item_custom_field_values_item_id_custom_field_id_unique');
|
||||
$table->foreign('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->foreign('custom_field_id')->references('id')->on('custom_fields')->onDelete('cascade');
|
||||
$table->unique(['item_id', 'custom_field_id', 'language_id'], 'item_field_language_unique');
|
||||
});
|
||||
Schema::create('package_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('package_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['package_id', 'language_id']); // prevent duplicate translations
|
||||
});
|
||||
Schema::create('setting_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('setting_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->text('translated_value')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['setting_id', 'language_id']); // prevent duplicate translations
|
||||
});
|
||||
Schema::create('feature_section_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('feature_section_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
$table->unique(['feature_section_id', 'language_id'], 'feature_section_language_unique'); // prevent duplicate translations
|
||||
});
|
||||
Schema::create('country_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('country_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['country_id', 'language_id']);
|
||||
});
|
||||
|
||||
Schema::create('state_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('state_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['state_id', 'language_id']);
|
||||
});
|
||||
|
||||
Schema::create('city_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('city_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['city_id', 'language_id']);
|
||||
});
|
||||
Schema::create('area_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('area_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['area_id', 'language_id']);
|
||||
});
|
||||
Schema::create('report_reason_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('report_reason_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('reason');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['report_reason_id', 'language_id']);
|
||||
});
|
||||
Schema::create('blog_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('blog_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained()->onDelete('cascade');
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('tags',1000)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('verification_fields_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('verification_field_id')->constrained('verification_fields')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained('languages')->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['verification_field_id', 'language_id'],'verification_language_unique');
|
||||
});
|
||||
Schema::table('verification_field_values', function (Blueprint $table) {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropForeign(['verification_field_id']);
|
||||
|
||||
$table->dropUnique('verification_field_values_user_id_verification_field_id_unique');
|
||||
|
||||
if (!Schema::hasColumn('verification_field_values', 'language_id')) {
|
||||
$table->foreignId('language_id')->nullable()->after('verification_request_id');
|
||||
}
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('verification_field_id')->references('id')->on('verification_fields')->onDelete('cascade');
|
||||
$table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'verification_field_id', 'language_id'], 'user_field_language_unique');
|
||||
});
|
||||
Schema::create('faq_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('question');
|
||||
$table->text('answer');
|
||||
$table->timestamps();
|
||||
$table->foreignId('faq_id')->constrained('faqs')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained('languages')->onDelete('cascade');
|
||||
$table->unique(['faq_id', 'language_id'],'faq_language_unique');
|
||||
});
|
||||
Schema::create('seo_settings_translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->string('keywords')->nullable();
|
||||
$table->foreignId('seo_setting_id')->constrained('seo_settings')->onDelete('cascade');
|
||||
$table->foreignId('language_id')->constrained('languages')->onDelete('cascade');
|
||||
|
||||
$table->timestamps();
|
||||
$table->unique(['seo_setting_id', 'language_id'], 'seo_setting_language_unique');
|
||||
});
|
||||
Schema::table('category_translations', function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->after('name');
|
||||
});
|
||||
Schema::table('payment_transactions', function (Blueprint $table) {
|
||||
// Add package_id column as nullable first
|
||||
$table->unsignedBigInteger('package_id')->nullable()->after('user_id');
|
||||
});
|
||||
|
||||
// Optionally: Fill existing rows with a default package_id if needed
|
||||
// DB::table('payment_transactions')->update(['package_id' => 1]); // Example
|
||||
|
||||
Schema::table('payment_transactions', function (Blueprint $table) {
|
||||
// Add foreign key constraint
|
||||
$table->foreign('package_id')
|
||||
->references('id')
|
||||
->on('packages')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('payment_configurations', function (Blueprint $table) {
|
||||
$table->dropColumn('additional_data_1');
|
||||
$table->dropColumn('additional_data_1');
|
||||
$table->dropColumn('payment_mode');
|
||||
});
|
||||
Schema::dropIfExists('item_translations');
|
||||
Schema::dropIfExists('custom_fields_translations');
|
||||
Schema::table('item_custom_field_values', function (Blueprint $table) {
|
||||
$table->dropColumn('language_id');
|
||||
});
|
||||
Schema::table('item_custom_field_values', function (Blueprint $table) {
|
||||
$table->dropForeign(['item_id']);
|
||||
$table->dropForeign(['custom_field_id']);
|
||||
$table->dropUnique('item_field_language_unique');
|
||||
$table->unique(['item_id', 'custom_field_id'], 'item_custom_field_values_item_id_custom_field_id_unique');
|
||||
$table->foreign('item_id')->references('id')->on('items')->onDelete('cascade');
|
||||
$table->foreign('custom_field_id')->references('id')->on('custom_fields')->onDelete('cascade');
|
||||
});
|
||||
Schema::dropIfExists('package_translations');
|
||||
Schema::dropIfExists('setting_translations');
|
||||
Schema::dropIfExists('feature_section_translations');
|
||||
Schema::dropIfExists('country_translations');
|
||||
Schema::dropIfExists('state_translations');
|
||||
Schema::dropIfExists('city_translations');
|
||||
Schema::dropIfExists('area_translations');
|
||||
Schema::dropIfExists('report_reason_translations');
|
||||
Schema::dropIfExists('blog_translations');
|
||||
Schema::dropIfExists('verification_fields_translations');
|
||||
Schema::table('verification_field_values', function (Blueprint $table) {
|
||||
$table->dropUnique('user_field_language_unique');
|
||||
$table->unique(['user_id', 'verification_field_id']);
|
||||
$table->dropForeign(['language_id']);
|
||||
$table->dropColumn('language_id');
|
||||
});
|
||||
Schema::dropIfExists('faq_translations');
|
||||
Schema::dropIfExists('seo_settings_translations');
|
||||
Schema::table('category_translations', function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
Schema::table('payment_transactions', function (Blueprint $table) {
|
||||
$table->dropForeign(['package_id']);
|
||||
$table->dropColumn('package_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
124
database/migrations/2025_10_16_150000_v2.8.0.php.php
Normal file
124
database/migrations/2025_10_16_150000_v2.8.0.php.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->foreignId('package_id')
|
||||
->nullable()
|
||||
->constrained('packages')
|
||||
->onDelete('set null'); // if package deleted → set null
|
||||
});
|
||||
|
||||
$updates = [
|
||||
'item-listing-package' => 'advertisement-listing-package',
|
||||
'advertisement-package' => 'featured-advertisement-package',
|
||||
'item' => 'advertisement',
|
||||
];
|
||||
|
||||
Permission::chunk(100, function ($permissions) use ($updates) {
|
||||
$updatedPermissions = [];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
$oldName = $permission->name;
|
||||
$newName = $oldName;
|
||||
|
||||
foreach ($updates as $oldPrefix => $newPrefix) {
|
||||
// Rename if permission name starts with this prefix
|
||||
if (str_starts_with($oldName, $oldPrefix . '-')) {
|
||||
$newName = preg_replace(
|
||||
'/^' . preg_quote($oldPrefix, '/') . '-/',
|
||||
$newPrefix . '-',
|
||||
$oldName
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If name changed and doesn’t already exist, schedule for update
|
||||
if ($newName !== $oldName &&
|
||||
!Permission::where('name', $newName)
|
||||
->where('guard_name', $permission->guard_name)
|
||||
->exists()) {
|
||||
$updatedPermissions[] = [
|
||||
'id' => $permission->id,
|
||||
'name' => $newName,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($updatedPermissions)) {
|
||||
Permission::upsert($updatedPermissions, ['id'], ['name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('payment_configurations', function (Blueprint $table) {
|
||||
$table->string('username')->nullable();
|
||||
$table->string('password')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->dropForeign(['package_id']);
|
||||
$table->dropColumn('package_id');
|
||||
});
|
||||
|
||||
$reverses = [
|
||||
'advertisement-listing-package' => 'item-listing-package',
|
||||
'featured-advertisement-package' => 'advertisement-package',
|
||||
'advertisement' => 'item',
|
||||
];
|
||||
|
||||
Permission::chunk(100, function ($permissions) use ($reverses) {
|
||||
$revertedPermissions = [];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
$oldName = $permission->name;
|
||||
$newName = $oldName;
|
||||
|
||||
foreach ($reverses as $oldPrefix => $newPrefix) {
|
||||
if (str_starts_with($oldName, $oldPrefix . '-')) {
|
||||
$newName = preg_replace(
|
||||
'/^' . preg_quote($oldPrefix, '/') . '-/',
|
||||
$newPrefix . '-',
|
||||
$oldName
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newName !== $oldName &&
|
||||
!Permission::where('name', $newName)
|
||||
->where('guard_name', $permission->guard_name)
|
||||
->exists()) {
|
||||
$revertedPermissions[] = [
|
||||
'id' => $permission->id,
|
||||
'name' => $newName,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($revertedPermissions)) {
|
||||
Permission::upsert($revertedPermissions, ['id'], ['name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('payment_configurations', function (Blueprint $table) {
|
||||
$table->dropColumn(['username', 'password']);
|
||||
});
|
||||
}
|
||||
};
|
||||
35
database/migrations/2025_12_03_113259_v2.9.0.php
Normal file
35
database/migrations/2025_12_03_113259_v2.9.0.php
Normal file
@@ -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::table('users', function (Blueprint $table) {
|
||||
$table->string('region_code')->nullable()->after('country_code');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('region_code')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('region_code');
|
||||
});
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->dropColumn('region_code');
|
||||
});
|
||||
}
|
||||
};
|
||||
144
database/migrations/2026_01_22_073809_v2.10.0.php
Normal file
144
database/migrations/2026_01_22_073809_v2.10.0.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// 1. Custom Fields Translation Name Nullable
|
||||
Schema::whenTableHasColumn('custom_fields_translations', 'name', function (Blueprint $table) {
|
||||
$table->string('name')->nullable()->change();
|
||||
});
|
||||
|
||||
// 2. Add Package Columns
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->enum('listing_duration_type', ['standard', 'package', 'custom'])->nullable()->after('duration');
|
||||
$table->integer('listing_duration_days')->nullable()->after('listing_duration_type');
|
||||
$table->longText('key_points')->nullable()->after('description');
|
||||
$table->tinyInteger('is_global')->default(1)->after('type');
|
||||
});
|
||||
|
||||
// 3. Create Pivot Table
|
||||
Schema::create('package_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('package_id')->constrained('packages')->onDelete('cascade');
|
||||
$table->foreignId('category_id')->constrained('categories')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
$table->unique(['package_id', 'category_id']);
|
||||
});
|
||||
|
||||
// 4. Update Sliders
|
||||
Schema::table('sliders', function (Blueprint $table) {
|
||||
$table->foreignId('country_id')->nullable()->after('id')->constrained('countries')->nullOnDelete();
|
||||
$table->foreignId('state_id')->nullable()->after('country_id')->constrained('states')->nullOnDelete();
|
||||
$table->foreignId('city_id')->nullable()->after('state_id')->constrained('cities')->nullOnDelete();
|
||||
});
|
||||
|
||||
// 5. Create Currencies & Update Countries
|
||||
Schema::create('currencies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('country_id')->nullable()->constrained('countries')->cascadeOnDelete();
|
||||
$table->char('iso_code', 3)->unique()->comment('ISO 4217 currency code');
|
||||
$table->string('name', 100)->unique()->comment('Currency name');
|
||||
$table->string('symbol', 10)->comment('Currency symbol');
|
||||
$table->enum('symbol_position', ['left', 'right'])->default('left')->comment('Currency symbol position');
|
||||
$table->unsignedTinyInteger('decimal_places')->default(2);
|
||||
$table->string('thousand_separator', 5)->default(',');
|
||||
$table->string('decimal_separator', 5)->default('.');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::table('countries', function (Blueprint $table) {
|
||||
$table->foreignId('currency_id')->nullable()->constrained('currencies')->nullOnDelete();
|
||||
});
|
||||
|
||||
// 6. Update Items
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->boolean('show_mobile_number')->default(false)->after('show_only_to_premium');
|
||||
$table->foreignId('currency_id')->after('price')->nullable()->constrained('currencies')->nullOnDelete();
|
||||
$table->string('contact')->nullable()->change();
|
||||
});
|
||||
|
||||
// 7. Translations & OTPs
|
||||
Schema::table('package_translations', function (Blueprint $table) {
|
||||
$table->longText('key_points')->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('number_otps', function (Blueprint $table) {
|
||||
$table->string('country_code', 10)->after('number')->nullable();
|
||||
});
|
||||
|
||||
// 8. Jobs Table
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
// 9. Modify Package Column Type (Enum to Varchar)
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
DB::statement('ALTER TABLE packages MODIFY listing_duration_type VARCHAR(255) NULL');
|
||||
});
|
||||
|
||||
// 10. User Purchased Packages Columns
|
||||
Schema::table('user_purchased_packages', function (Blueprint $table) {
|
||||
$table->string('listing_duration_type')->nullable(); // Set as string to match parent
|
||||
$table->integer('listing_duration_days')->nullable()->after('listing_duration_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_purchased_packages', function (Blueprint $table) {
|
||||
$table->dropColumn(['listing_duration_type', 'listing_duration_days']);
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->dropForeign(['currency_id']);
|
||||
$table->dropColumn(['show_mobile_number', 'currency_id']);
|
||||
$table->string('contact')->nullable(false)->change();
|
||||
});
|
||||
|
||||
Schema::table('countries', function (Blueprint $table) {
|
||||
$table->dropForeign(['currency_id']);
|
||||
$table->dropColumn('currency_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('currencies');
|
||||
Schema::dropIfExists('package_categories');
|
||||
Schema::dropIfExists('jobs');
|
||||
|
||||
Schema::table('number_otps', function (Blueprint $table) {
|
||||
$table->dropColumn('country_code');
|
||||
});
|
||||
|
||||
Schema::table('package_translations', function (Blueprint $table) {
|
||||
$table->dropColumn('key_points');
|
||||
});
|
||||
|
||||
Schema::table('sliders', function (Blueprint $table) {
|
||||
$table->dropForeign(['country_id']);
|
||||
$table->dropForeign(['state_id']);
|
||||
$table->dropForeign(['city_id']);
|
||||
$table->dropColumn(['country_id', 'state_id', 'city_id']);
|
||||
});
|
||||
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropColumn(['listing_duration_type', 'listing_duration_days', 'key_points', 'is_global']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user