-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from megoxv/master
Add multi-vendor (SaaS) and codes manager
- Loading branch information
Showing
19 changed files
with
745 additions
and
66 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
database/migrations/2024_09_17_085824_create_codes_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('codes', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('product_id')->constrained('products')->onDelete('cascade'); | ||
$table->string('code'); | ||
$table->boolean('is_used')->default(false); | ||
$table->timestamp('used_at')->nullable(); | ||
$table->timestamp('expires_at')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('codes'); | ||
} | ||
}; |
55 changes: 55 additions & 0 deletions
55
database/migrations/2024_09_17_113838_add_team_id_to_ecommerce.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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 | ||
{ | ||
$tables = [ | ||
'products', | ||
'coupons', | ||
'companies', | ||
'gift_cards', | ||
'referral_codes', | ||
'shipping_vendors', | ||
'orders' | ||
]; | ||
|
||
foreach ($tables as $table) { | ||
Schema::table($table, function (Blueprint $table) { | ||
$table->unsignedBigInteger('team_id')->nullable()->after('id'); | ||
$table->foreign('team_id')->references('id')->on('teams')->nullOnDelete(); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
$tables = [ | ||
'products', | ||
'coupons', | ||
'companies', | ||
'gift_cards', | ||
'referral_codes', | ||
'shipping_vendors', | ||
'deliveries', | ||
'orders' | ||
]; | ||
|
||
foreach ($tables as $table) { | ||
Schema::table($table, function (Blueprint $table) { | ||
$table->dropForeign(['team_id']); | ||
$table->dropColumn('team_id'); | ||
}); | ||
} | ||
} | ||
}; |
28 changes: 28 additions & 0 deletions
28
database/migrations/2024_09_21_185907_add_code_to_orders_items_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('orders_items', function (Blueprint $table) { | ||
$table->string('code')->nullable()->after('qty'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('orders_items', function (Blueprint $table) { | ||
$table->dropColumn('code'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.