Skip to content

Commit

Permalink
Merge pull request #10 from megoxv/master
Browse files Browse the repository at this point in the history
Add multi-vendor (SaaS) and codes manager
  • Loading branch information
3x1io authored Sep 26, 2024
2 parents cec177a + f36b091 commit 788dd08
Show file tree
Hide file tree
Showing 19 changed files with 745 additions and 66 deletions.
32 changes: 32 additions & 0 deletions database/migrations/2024_09_17_085824_create_codes_table.php
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 database/migrations/2024_09_17_113838_add_team_id_to_ecommerce.php
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');
});
}
}
};
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');
});
}
};
48 changes: 48 additions & 0 deletions resources/lang/ar/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
'keywords' => 'الكلمات الدالة',
'is_in_stock' => 'متوفر في المخزون',
'has_options' => 'يحتوي على خيارات',
'product' => 'منتج مادي',
'digital' => 'منتج رقمي',
'service' => 'خدمة',
"retail" => "تجزئة",
"wholesale" => "جملة",
"special" => "خاص",
"items" => "عناصر",
'options' => [
'title' => 'الخيارات',
'has_custom_price' => 'لديه سعر مخصص',
Expand Down Expand Up @@ -211,6 +218,7 @@
'billed_to' => "المستحق لـ:",
'total' => "الإجمالي",
'qty' => "الكمية",
'code' => "الكود",
'price' => "السعر",
'discount' => "الخصم",
'vat' => "الضريبة",
Expand Down Expand Up @@ -416,5 +424,45 @@
"is_activated" => "مفعل",
"is_public" => "عام",
]
],
"codes" => [
"title" => "الأكواد",
"single" => "كود",
"columns" => [
"code" => "الكود",
"is_used" => "تم استخدامه",
"used_at" => "تاريخ الاستخدام",
"unused" => "غير مستخدم",
"expires_date" => "تاريخ الانتهاء (اتركه فارغًا لعدم وجود انتهاء)",
"expires_at" => "ينتهي في",
"no_expiration" => "بدون انتهاء",
],
"filters" => [
"used" => "مستخدم",
"unused" => "غير مستخدم",
"usage_status" => "حالة الاستخدام",
"expiration_status" => "حالة الانتهاء",
"expired" => "منتهي",
"not_expired" => "غير منتهي",
"no_expiration" => "بدون انتهاء",
"expiring_soon" => "ينتهي قريبًا (خلال 7 أيام)",
],
"generate" => [
"generate_codes" => "توليد اكواد",
"quantity" => "عدد الأكواد",
"prefix" => "بادئة الكود",
"suffix" => "لاحقة الكود",
"code_type" => "نوع الكود",
"alphanumeric" => "أبجدي رقمي",
"alphabetic" => "أبجدي",
"numeric" => "رقمي",
"code_case" => "حالة الكود",
"upper" => "أحرف كبيرة",
"lower" => "أحرف صغيرة",
"mixed" => "حالات مختلطة",
"code_length" => "طول الكود",
"has_expiration" => "تحديد تاريخ الانتهاء",
"expires_at" => "تاريخ الانتهاء",
]
]
];
48 changes: 48 additions & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
'keywords' => 'Keywords',
'is_in_stock' => 'Is In Stock',
'has_options' => 'Has Variants',
'product' => 'Product',
'digital' => 'Digital',
'service' => 'Service',
"retail" => "Retail",
"wholesale" => "Wholesale",
"special" => "Special",
"items" => "Items",
'options' => [
'title' => 'Variants',
'has_custom_price' => 'Has Custom Price',
Expand Down Expand Up @@ -204,6 +211,7 @@
'billed_to' => "Billed To: ",
'total' => "Total",
'qty' => "Qty",
'code' => "Code",
'price' => "Price",
'coupon' => "Discount Coupon",
'discount' => "Discount",
Expand Down Expand Up @@ -419,5 +427,45 @@
"is_activated" => "Is Activated",
"is_public" => "Is Public",
]
],
"codes" => [
"title" => "Codes",
"single" => "Code",
"columns" => [
"code" => "Code",
"is_used" => "Is used",
"used_at" => "Used at",
"unused" => "Unused",
"expires_date" => "Expiration Date (leave empty for no expiration)",
"expires_at" => "Expires at",
"no_expiration" => "No Expiration",
],
"filters" => [
"used" => "Used",
"unused" => "Unused",
"usage_status" => "Usage Status",
"expiration_status" => "Expiration Status",
"expired" => "Expired",
"not_expired" => "Not Expired",
"no_expiration" => "No Expiration",
"expiring_soon" => "Expiring Soon (7 days)",
],
"generate" => [
"generate_codes" => "Generate Codes",
"quantity" => "Number of Codes",
"prefix" => "Code Prefix",
"suffix" => "Code Suffix",
"code_type" => "Code Type",
"alphanumeric" => "Alphanumeric",
"alphabetic" => "Alphabetic",
"numeric" => "Numeric",
"code_case" => "Code Case",
"upper" => "Uppercase",
"lower" => "Lowercase",
"mixed" => "Mixed Case",
"code_length" => "Code Length",
"has_expiration" => "Set Expiration Date",
"expires_at" => "Expiration Date",
]
]
];
4 changes: 3 additions & 1 deletion src/Filament/Resources/OrderResource/Pages/ListOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,14 @@ protected function getHeaderActions(): array
{
return [
Actions\Action::make('setting')
->hidden(!filament('filament-ecommerce')->useOrderSettings)
->hiddenLabel()
->tooltip(trans('filament-ecommerce::messages.orders.actions.settings'))
->color('warning')
->url(OrderSettingsPage::getUrl())
->icon('heroicon-o-cog'),
Actions\CreateAction::make(),
Actions\CreateAction::make()
->hidden(!filament('filament-ecommerce')->allowOrderCreate),
];
}
}
37 changes: 19 additions & 18 deletions src/Filament/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public static function form(Form $form): Form
->columnSpanFull()
->searchable()
->options([
"product" => "Product",
"digital" => "Digital",
"service" => "Service",
"product" => trans('filament-ecommerce::messages.product.columns.product'),
"digital" => trans('filament-ecommerce::messages.product.columns.digital'),
"service" => trans('filament-ecommerce::messages.product.columns.service'),
])
->label(trans('filament-ecommerce::messages.product.columns.type'))
->default('product'),
Expand Down Expand Up @@ -135,10 +135,10 @@ public static function form(Form $form): Form
->searchable()
->live()
->options([
"retail" => "Retail",
"wholesale" => "Wholesale",
"special" => "Special",
"items" => "Items",
"retail" => trans('filament-ecommerce::messages.product.columns.retail'),
"wholesale" => trans('filament-ecommerce::messages.product.columns.wholesale'),
"special" => trans('filament-ecommerce::messages.product.columns.special'),
"items" => trans('filament-ecommerce::messages.product.columns.items'),
])
->default('retail')
->label(trans('filament-ecommerce::messages.product.columns.for'))
Expand Down Expand Up @@ -295,10 +295,10 @@ public static function form(Form $form): Form
->searchable()
->live()
->options([
"retail" => "Retail",
"wholesale" => "Wholesale",
"special" => "Special",
"items" => "Items",
"retail" => trans('filament-ecommerce::messages.product.columns.retail'),
"wholesale" => trans('filament-ecommerce::messages.product.columns.wholesale'),
"special" => trans('filament-ecommerce::messages.product.columns.special'),
"items" => trans('filament-ecommerce::messages.product.columns.items'),
])
->default('retail')
->required(),
Expand Down Expand Up @@ -363,9 +363,9 @@ public static function table(Table $table): Table
Tables\Columns\TextColumn::make('type')
->badge()
->state(fn(Product $product) => match ($product->type) {
'product' => 'Product',
'digital' => 'Digital',
'service' => 'Service',
'product' => trans('filament-ecommerce::messages.product.columns.product'),
'digital' => trans('filament-ecommerce::messages.product.columns.digital'),
'service' => trans('filament-ecommerce::messages.product.columns.service'),
})
->color(fn(Product $product) => match ($product->type) {
'product' => 'primary',
Expand Down Expand Up @@ -438,9 +438,9 @@ public static function table(Table $table): Table
->label(trans('filament-ecommerce::messages.product.filters.type'))
->searchable()
->options([
"product" => "Product",
"digital" => "Digital",
"service" => "Service",
'product' => trans('filament-ecommerce::messages.product.columns.product'),
'digital' => trans('filament-ecommerce::messages.product.columns.digital'),
'service' => trans('filament-ecommerce::messages.product.columns.service'),
]),
Tables\Filters\TernaryFilter::make('is_activated')
->label(trans('filament-ecommerce::messages.product.filters.is_activated')),
Expand Down Expand Up @@ -471,7 +471,8 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
RelationManagers\ProductReviewManager::make()
RelationManagers\ProductReviewManager::make(),
RelationManagers\CodesManager::make()
];
}

Expand Down
Loading

0 comments on commit 788dd08

Please sign in to comment.