From a7becdbf40989d100b95a087669c19d06cd8a7ad Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Fri, 14 Jun 2024 22:16:04 +0300 Subject: [PATCH] improve plans resources --- composer.lock | 109 +++--- .../2022_03_05_200700_create_plans_table.php | 1 + resources/lang/ar/plan.php | 93 +++++ src/Filament/Resources/PlanResource.php | 318 +++++++++++------- .../PlanResource/Pages/CreatePlan.php | 4 +- .../Resources/PlanResource/Pages/EditPlan.php | 4 +- .../PlanResource/Pages/ListPlans.php | 4 +- src/Models/Features.php | 6 +- src/Models/Intervals.php | 10 +- src/PontusServiceProvider.php | 1 + 10 files changed, 355 insertions(+), 195 deletions(-) create mode 100644 resources/lang/ar/plan.php diff --git a/composer.lock b/composer.lock index f9ae11c..bde6eb8 100644 --- a/composer.lock +++ b/composer.lock @@ -407,16 +407,16 @@ }, { "name": "danharrin/date-format-converter", - "version": "v0.3.0", + "version": "v0.3.1", "source": { "type": "git", "url": "https://github.com/danharrin/date-format-converter.git", - "reference": "42b6ddc52059d4ba228a67c15adaaa0c039e75f2" + "reference": "7c31171bc981e48726729a5f3a05a2d2b63f0b1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/danharrin/date-format-converter/zipball/42b6ddc52059d4ba228a67c15adaaa0c039e75f2", - "reference": "42b6ddc52059d4ba228a67c15adaaa0c039e75f2", + "url": "https://api.github.com/repos/danharrin/date-format-converter/zipball/7c31171bc981e48726729a5f3a05a2d2b63f0b1e", + "reference": "7c31171bc981e48726729a5f3a05a2d2b63f0b1e", "shasum": "" }, "require": { @@ -454,7 +454,7 @@ "type": "github" } ], - "time": "2022-09-29T07:48:20+00:00" + "time": "2024-06-13T09:38:44+00:00" }, { "name": "danharrin/livewire-rate-limiting", @@ -680,16 +680,16 @@ }, { "name": "doctrine/dbal", - "version": "3.8.4", + "version": "3.8.5", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd" + "reference": "0e3536ba088a749985c8801105b6b3ac6c1280b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/b05e48a745f722801f55408d0dbd8003b403dbbd", - "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/0e3536ba088a749985c8801105b6b3ac6c1280b6", + "reference": "0e3536ba088a749985c8801105b6b3ac6c1280b6", "shasum": "" }, "require": { @@ -705,12 +705,12 @@ "doctrine/coding-standard": "12.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "1.10.58", - "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpunit": "9.6.16", + "phpstan/phpstan": "1.11.1", + "phpstan/phpstan-strict-rules": "^1.6", + "phpunit/phpunit": "9.6.19", "psalm/plugin-phpunit": "0.18.4", "slevomat/coding-standard": "8.13.1", - "squizlabs/php_codesniffer": "3.9.0", + "squizlabs/php_codesniffer": "3.9.2", "symfony/cache": "^5.4|^6.0|^7.0", "symfony/console": "^4.4|^5.4|^6.0|^7.0", "vimeo/psalm": "4.30.0" @@ -773,7 +773,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.8.4" + "source": "https://github.com/doctrine/dbal/tree/3.8.5" }, "funding": [ { @@ -789,7 +789,7 @@ "type": "tidelift" } ], - "time": "2024-04-25T07:04:44+00:00" + "time": "2024-06-08T17:49:56+00:00" }, { "name": "doctrine/deprecations", @@ -1227,16 +1227,16 @@ }, { "name": "filament/actions", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/actions.git", - "reference": "483557cc10c84c8536e12280da7855bf53c2a4e2" + "reference": "99bf5ed84e3a563250775c223928b185db0d4b7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/actions/zipball/483557cc10c84c8536e12280da7855bf53c2a4e2", - "reference": "483557cc10c84c8536e12280da7855bf53c2a4e2", + "url": "https://api.github.com/repos/filamentphp/actions/zipball/99bf5ed84e3a563250775c223928b185db0d4b7a", + "reference": "99bf5ed84e3a563250775c223928b185db0d4b7a", "shasum": "" }, "require": { @@ -1276,20 +1276,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-06-10T12:07:37+00:00" + "time": "2024-06-14T10:24:05+00:00" }, { "name": "filament/filament", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/panels.git", - "reference": "c89fcc0ef9f9d9222cc25bcd4f7c327a23c8352c" + "reference": "4e1a260a78487375dc025acbdd07c3561aabd8e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/panels/zipball/c89fcc0ef9f9d9222cc25bcd4f7c327a23c8352c", - "reference": "c89fcc0ef9f9d9222cc25bcd4f7c327a23c8352c", + "url": "https://api.github.com/repos/filamentphp/panels/zipball/4e1a260a78487375dc025acbdd07c3561aabd8e0", + "reference": "4e1a260a78487375dc025acbdd07c3561aabd8e0", "shasum": "" }, "require": { @@ -1341,20 +1341,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-06-10T12:07:43+00:00" + "time": "2024-06-14T10:24:14+00:00" }, { "name": "filament/forms", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/forms.git", - "reference": "f58cc7d23ef2df1594f13d01e8dd016ed9033803" + "reference": "8708f598cf0bc1e747a8f59626d7166c7c94f149" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/forms/zipball/f58cc7d23ef2df1594f13d01e8dd016ed9033803", - "reference": "f58cc7d23ef2df1594f13d01e8dd016ed9033803", + "url": "https://api.github.com/repos/filamentphp/forms/zipball/8708f598cf0bc1e747a8f59626d7166c7c94f149", + "reference": "8708f598cf0bc1e747a8f59626d7166c7c94f149", "shasum": "" }, "require": { @@ -1397,20 +1397,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-06-10T12:07:33+00:00" + "time": "2024-06-14T10:24:06+00:00" }, { "name": "filament/infolists", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/infolists.git", - "reference": "82f96586e082905a7c86362e83309829f0d23bd0" + "reference": "59909a1206fb9961f7bd3ceb993b7e7a0c4d2215" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/infolists/zipball/82f96586e082905a7c86362e83309829f0d23bd0", - "reference": "82f96586e082905a7c86362e83309829f0d23bd0", + "url": "https://api.github.com/repos/filamentphp/infolists/zipball/59909a1206fb9961f7bd3ceb993b7e7a0c4d2215", + "reference": "59909a1206fb9961f7bd3ceb993b7e7a0c4d2215", "shasum": "" }, "require": { @@ -1448,11 +1448,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-06-10T12:07:27+00:00" + "time": "2024-06-13T07:04:01+00:00" }, { "name": "filament/notifications", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/notifications.git", @@ -1504,16 +1504,16 @@ }, { "name": "filament/support", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/support.git", - "reference": "a62d52739d661042123da30fa2b8e64e46bef901" + "reference": "852ec3783349d799141c302a4944d5303ece985d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/support/zipball/a62d52739d661042123da30fa2b8e64e46bef901", - "reference": "a62d52739d661042123da30fa2b8e64e46bef901", + "url": "https://api.github.com/repos/filamentphp/support/zipball/852ec3783349d799141c302a4944d5303ece985d", + "reference": "852ec3783349d799141c302a4944d5303ece985d", "shasum": "" }, "require": { @@ -1558,20 +1558,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-06-10T12:07:53+00:00" + "time": "2024-06-14T10:24:22+00:00" }, { "name": "filament/tables", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/tables.git", - "reference": "4debcc2b5dca501e6061a39c30565692c156ecd1" + "reference": "34ea607f95e45d0bf9580d47294a179b1457e0e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/tables/zipball/4debcc2b5dca501e6061a39c30565692c156ecd1", - "reference": "4debcc2b5dca501e6061a39c30565692c156ecd1", + "url": "https://api.github.com/repos/filamentphp/tables/zipball/34ea607f95e45d0bf9580d47294a179b1457e0e6", + "reference": "34ea607f95e45d0bf9580d47294a179b1457e0e6", "shasum": "" }, "require": { @@ -1611,11 +1611,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2024-06-10T12:07:59+00:00" + "time": "2024-06-13T07:04:15+00:00" }, { "name": "filament/widgets", - "version": "v3.2.87", + "version": "v3.2.91", "source": { "type": "git", "url": "https://github.com/filamentphp/widgets.git", @@ -8232,16 +8232,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -8249,11 +8249,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -8279,7 +8280,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -8287,7 +8288,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nikic/php-parser", diff --git a/database/migrations/2022_03_05_200700_create_plans_table.php b/database/migrations/2022_03_05_200700_create_plans_table.php index d86477b..6bca74d 100644 --- a/database/migrations/2022_03_05_200700_create_plans_table.php +++ b/database/migrations/2022_03_05_200700_create_plans_table.php @@ -20,6 +20,7 @@ public function up(): void $table->boolean('is_active')->default(true); $table->decimal('price')->default('0.00'); $table->decimal('signup_fee')->default('0.00'); + $table->string('subscription_model')->default('FIXED'); $table->string('currency', 3); $table->smallInteger('trial_period')->unsigned()->default(0); $table->string('trial_interval')->default('day'); diff --git a/resources/lang/ar/plan.php b/resources/lang/ar/plan.php new file mode 100644 index 0000000..f05ca4e --- /dev/null +++ b/resources/lang/ar/plan.php @@ -0,0 +1,93 @@ + 'الخطط', + 'singleTitle' => 'خطة', + + 'usages' => 'استهلاك الميزات', + 'usage' => 'استهلاك', + 'plan' => 'خطة', + 'the_plan' => 'الخطة', + 'plan_features' => 'مميرات الخطة', + 'amount' => 'المبلغ', + 'tax' => 'الضريبة', + 'discount_type' => 'نوع الخصم', + 'discount_value' => 'قيمة الخصم', + 'due_date' => 'تاريخ الاستحقاق', + 'exp_date' => 'تاريخ الانتهاء', + 'paid' => 'مدفوع', + 'allow_partial_paid' => 'السماح بالدفع الجزئي', + 'note' => 'ملاحظة', + 'subscriptions_title' => 'الاشتراكات والخطط', + 'plan_subscription' => 'اشتراك', + 'plan_subscriptions' => 'اشتراكات العملاء', + 'plan_user_subscription' => 'الاشتراك', + 'add_subscription' => 'اشتراك جديد', + 'subscriber' => 'العميل', + 'trial_ends_at' => 'تنتهي التجربة في', + 'starts_at' => 'يبدأ الإشتراك من', + 'ends_at' => 'ينتهي الإشتراك في', + 'used' => 'الاستخدام', + 'valid_until' => 'صالح لغاية', + 'features_description_hint' => 'الوصف الذي سيظهر في الفاتورة', + 'nameAndDesc' => 'اسم ووصف الخطة', + 'name' => 'اسم الخطة', + 'description' => 'الوصف', + 'slug' => 'الكود المختصر', + + 'hour' => 'ساعة', + 'day' => 'يوم', + 'week' => 'اسبوع', + 'month' => 'شهر', + 'year' => 'سنة', + + 'features' => [ + 'users' => 'الموظفين', + 'certificates' => 'الشهادات', + 'cooperative_training' => 'التدريب التعاوني', + ], + + 'plan_feature' => [ + 'name' => 'اسم الميزة', + 'slug' => 'كود الميزة', + 'slug_hint' => 'يتم استخدامها برمجيا', + 'description' => 'وصف الميرة', + 'value' => 'الكمية المسموح بها', + 'price' => 'السعر للوحدة', + 'price_hint' => 'للخطط المرنة فقط', + 'sort_order' => 'الترتيب', + 'resettable_period' => 'اعادة تعيين الكمية كل', + 'resettable_interval' => 'اعادة تعيين الكمية في', + 'for_static_plans' => 'للخطط الثابتة فقط', + ], + + 'plans_pricing' => 'تسعير الحطة', + 'price' => 'تسعير الحطة', + 'signup_fee' => 'رسوم الانضمام', + + 'plans_invoice' => 'فترة الفوترة', + 'invoice_period' => 'مدة الفوترة', + 'invoice_interval' => 'وحدة الفوترة', + + 'subscription_model' => 'نوع الخطة', + 'PAYG' => 'حسب الاستخدام', + 'FIXED' => 'ثابتة', + 'features_count' => 'عدد المميزات', + + 'plans_trials' => 'الفترة التجريبية', + 'trial_period' => 'المدة التجريبية', + 'trial_interval' => 'وحدة المدة التجريبية', + + 'plans_grace' => 'فترة السماح', + 'grace_period' => 'مدة السماح', + 'grace_interval' => 'وحدة السماح', + 'grace_hint' => 'فترة السماح للعميل لاستخدام النظام بعد انشاء الفاتورة', + + 'plans_options' => 'خيارات الخطة', + 'sort_order' => 'الترتيب في العرض', + 'currency' => 'العملة', + 'is_active' => 'مغعلة؟', + 'is_visible' => 'تظهر في الموقع؟', + 'active_subscribers_limit' => 'اقصى عدد للمشتركين في الخطة', + 'created_at' => 'اقصى عدد للمشتركين في الخطة', +]; diff --git a/src/Filament/Resources/PlanResource.php b/src/Filament/Resources/PlanResource.php index 938a3e2..8755ca3 100644 --- a/src/Filament/Resources/PlanResource.php +++ b/src/Filament/Resources/PlanResource.php @@ -14,166 +14,230 @@ use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Filter; use Filament\Tables\Table; +use LaraZeus\Chaos\Filament\ChaosResource\ChaosForms; +use LaraZeus\Chaos\Filament\ChaosResource\ChaosTables; use LaraZeus\Chaos\Forms\Components\MultiLang; use LaraZeus\Pontus\Filament\Resources\PlanResource\Pages; use LaraZeus\Pontus\Filament\Resources\PlanResource\Pages\CreatePlan; -use LaraZeus\Pontus\Models\Features; use LaraZeus\Pontus\Models\Intervals; class PlanResource extends PontusResource { + protected static ?int $navigationSort = 1; + + protected static ?string $langFile = 'zeus-pontus::plan.'; + public static function getModel(): string { return config('rinvex.subscriptions.models.plan'); } - protected static ?int $navigationSort = 1; + public static function getModelLabel(): string + { + return __(static::$langFile . 'singleTitle'); + } + + public static function getPluralModelLabel(): string + { + return __(static::$langFile . 'title'); + } public static function form(Form $form): Form { - return $form - ->columns(3) - ->schema( - [ - Grid::make() - ->columnSpan(2) - ->schema([ - - Section::make(__('.nameAndDesc')) - ->columns() - ->schema([ - MultiLang::make('name'), - TextInput::make('slug')->required(), - RichEditor::make('description')->columnSpanFull(), - ]), - - Repeater::make('plan_feature') - ->label(__('.plan_features')) - ->relationship('features') - ->columnSpanFull() - ->schema([ - Grid::make()->schema([ - TextInput::make('name') - ->required(), - Select::make('slug') - ->options(Features::pluck('label', 'code')), - ]), - - RichEditor::make('description')->required() - ->hint(__('.features_description_hint')), - - Grid::make()->schema([ - TextInput::make('value')->required() - ->hint(__('.plan_feature.for_static_plans')), - TextInput::make('price') - ->hint(__('.plan_feature.price_hint')) - ->default(0) - ->required(), - TextInput::make('sort_order') - ->required(), - ]), - - Grid::make()->schema([ - TextInput::make('resettable_period') - ->required(), - Select::make('resettable_interval') - ->options(Intervals::pluck('label', 'name')), - ]), - ]), - ]), + return ChaosForms::make( + $form, + [ + Section::make('nameAndDesc') + ->heading(__(static::$langFile . 'nameAndDesc')) + ->columns() + ->schema([ + MultiLang::make('name') + ->label(__(static::$langFile . 'name')), + TextInput::make('slug') + ->unique(ignoreRecord: true) + ->label(__(static::$langFile . 'slug')) + ->required(), + RichEditor::make('description') + ->label(__(static::$langFile . 'description')) + ->columnSpanFull(), + ]), - Grid::make()->columnSpan(1)->schema([ - Section::make() - ->columns() + Repeater::make('plan_feature') + ->label(__(static::$langFile . 'plan_features')) + ->relationship('features') + ->columnSpanFull() + ->collapsible() + ->reorderable() + ->schema([ + Grid::make() ->schema([ - TextInput::make('price') - ->required() - ->default(0), - TextInput::make('signup_fee') - ->required() - ->default(0), - Select::make('subscription_model') - ->columnSpanFull() - ->default('PAYG') - ->options([ - 'PAYG' => __('subscription.PAYG'), - 'FIXED' => __('subscription.FIXED'), - ]), + MultiLang::make('name') + ->label(__(static::$langFile . 'name')), + Select::make('slug') + ->label(__(static::$langFile . 'plan_feature.slug')) + ->options(config('zeus-pontus.models.Features')::pluck('label', 'code')), ]), - Section::make() - ->compact() - ->heading(__('.plans_invoice')) - ->schema([ - TextInput::make('invoice_period') - ->required() - ->integer() - ->default(1), - Select::make('invoice_interval') - ->options(Intervals::pluck( - 'label', - 'name' - )) - ->default('month'), - ]), + RichEditor::make('description') + ->label(__(static::$langFile . 'description')) + ->required() + ->hint(__(static::$langFile . 'features_description_hint')), - Section::make() - ->label(__('.plans_trials')) - ->compact() + Grid::make() ->schema([ - TextInput::make('trial_period') + TextInput::make('value') ->required() - ->integer() - ->default(15), - Select::make('trial_interval') - ->options(Intervals::pluck('label', 'name')) - ->default('day'), + ->label(__(static::$langFile . 'plan_feature.value')) + ->hint(__(static::$langFile . 'plan_feature.for_static_plans')), + TextInput::make('price') + ->label(__(static::$langFile . 'price')) + ->hint(__(static::$langFile . 'plan_feature.price_hint')) + ->default(0) + ->required(), + TextInput::make('sort_order') + ->label(__(static::$langFile . 'sort_order')) + ->required(), ]), - Section::make() - ->compact() - ->label('.plans_grace') - ->schema([ - TextInput::make('grace_period')->required() - ->integer() - ->default(15), - Select::make('grace_interval') - ->label(__('subscription.grace_interval')) - ->options(Intervals::pluck('label', 'name')) - ->default('day'), + Grid::make()->schema([ + TextInput::make('resettable_period') + ->label(__(static::$langFile . 'plan_feature.resettable_period')) + ->required(), + Select::make('resettable_interval') + ->default('month') + ->label(__(static::$langFile . 'plan_feature.resettable_interval')) + ->options(Intervals::pluck('label', 'name')), + ]), + ]), + ], + [ + Section::make() + ->columns() + ->compact() + ->schema([ + TextInput::make('price') + ->label(__(static::$langFile . 'price')) + ->required() + ->default(0), + TextInput::make('signup_fee') + ->label(__(static::$langFile . 'signup_fee')) + ->required() + ->default(0), + Select::make('subscription_model') + ->label(__(static::$langFile . 'subscription_model')) + ->columnSpanFull() + ->default('PAYG') + ->options([ + 'PAYG' => __(static::$langFile . 'PAYG'), + 'FIXED' => __(static::$langFile . 'FIXED'), ]), + ]), - Section::make() - ->compact() - ->label('.plans_options') - ->schema([ - TextInput::make('sort_order')->required()->integer(), - TextInput::make('currency')->default('SAR')->maxLength(3), - TextInput::make('active_subscribers_limit')->integer(), - Toggle::make('is_active')->required(), - Toggle::make('is_visible')->required(), - ]), + Section::make() + ->compact() + ->heading(__(static::$langFile . 'plans_invoice')) + ->schema([ + TextInput::make('invoice_period') + ->label(__(static::$langFile . 'invoice_period')) + ->required() + ->integer() + ->default(1), + Select::make('invoice_interval') + ->label(__(static::$langFile . 'invoice_interval')) + ->options(Intervals::pluck( + 'label', + 'name' + )) + ->default('month'), + ]), + + Section::make() + ->heading(__(static::$langFile . 'plans_trials')) + ->compact() + ->schema([ + TextInput::make('trial_period') + ->label(__(static::$langFile . 'trial_period')) + ->required() + ->integer() + ->default(15), + Select::make('trial_interval') + ->label(__(static::$langFile . 'trial_interval')) + ->options(Intervals::pluck('label', 'name')) + ->default('day'), + ]), + + Section::make() + ->compact() + ->heading(__(static::$langFile . 'plans_grace')) + ->schema([ + TextInput::make('grace_period') + ->label(__(static::$langFile . 'grace_period')) + ->required() + ->integer() + ->default(15), + Select::make('grace_interval') + ->label(__(static::$langFile . 'grace_interval')) + ->options(Intervals::pluck('label', 'name')) + ->default('day'), + ]), + + Section::make() + ->compact() + ->heading(__(static::$langFile . 'plans_options')) + ->schema([ + TextInput::make('sort_order') + ->label(__(static::$langFile . 'sort_order')) + ->required() + ->default(1) + ->integer(), + TextInput::make('currency') + ->label(__(static::$langFile . 'currency')) + ->default('SAR') + ->maxLength(3), + TextInput::make('active_subscribers_limit') + ->label(__(static::$langFile . 'active_subscribers_limit')) + ->integer(), + Toggle::make('is_active') + ->label(__(static::$langFile . 'is_active')) + ->required(), + Toggle::make('is_visible') + ->label(__(static::$langFile . 'is_visible')) + ->required(), ]), - ] - ); + ] + ) + ->columns(3); } public static function table(Table $table): Table { - return $table - ->columns([ - TextColumn::make('slug'), - TextColumn::make('name'), - TextColumn::make('subscription_model'), - IconColumn::make('is_active')->boolean(), - IconColumn::make('is_visible')->boolean(), - TextColumn::make('price'), - TextColumn::make('features_count')->counts('features'), - ]) - ->filters([ + return ChaosTables::make( + resource: static::class, + table: $table, + columns: [ + TextColumn::make('slug') + ->label(__(static::$langFile . 'slug')), + TextColumn::make('name') + ->label(__(static::$langFile . 'name')), + TextColumn::make('subscription_model') + ->label(__(static::$langFile . 'subscription_model')), + IconColumn::make('is_active') + ->label(__(static::$langFile . 'is_active')) + ->boolean(), + IconColumn::make('is_visible') + ->label(__(static::$langFile . 'is_visible')) + ->boolean(), + TextColumn::make('price') + ->label(__(static::$langFile . 'price')), + TextColumn::make('features_count') + ->label(__(static::$langFile . 'features_count')) + ->counts('features'), + ], + filters: [ Filter::make('is_active')->label(__('subscription.is_active')), Filter::make('is_visible')->label(__('subscription.is_visible')), - ]); + ] + ); } public static function getPages(): array diff --git a/src/Filament/Resources/PlanResource/Pages/CreatePlan.php b/src/Filament/Resources/PlanResource/Pages/CreatePlan.php index 9cef574..33e2169 100644 --- a/src/Filament/Resources/PlanResource/Pages/CreatePlan.php +++ b/src/Filament/Resources/PlanResource/Pages/CreatePlan.php @@ -2,10 +2,10 @@ namespace LaraZeus\Pontus\Filament\Resources\PlanResource\Pages; -use Filament\Resources\Pages\CreateRecord; +use LaraZeus\Chaos\Filament\ChaosResource\Pages\ChaosCreateRecord; use LaraZeus\Pontus\Filament\Resources\PlanResource; -class CreatePlan extends CreateRecord +class CreatePlan extends ChaosCreateRecord { protected static string $resource = PlanResource::class; } diff --git a/src/Filament/Resources/PlanResource/Pages/EditPlan.php b/src/Filament/Resources/PlanResource/Pages/EditPlan.php index 41f567d..f91363b 100644 --- a/src/Filament/Resources/PlanResource/Pages/EditPlan.php +++ b/src/Filament/Resources/PlanResource/Pages/EditPlan.php @@ -2,10 +2,10 @@ namespace LaraZeus\Pontus\Filament\Resources\PlanResource\Pages; -use Filament\Resources\Pages\EditRecord; +use LaraZeus\Chaos\Filament\ChaosResource\Pages\ChaosEditRecord; use LaraZeus\Pontus\Filament\Resources\PlanResource; -class EditPlan extends EditRecord +class EditPlan extends ChaosEditRecord { protected static string $resource = PlanResource::class; } diff --git a/src/Filament/Resources/PlanResource/Pages/ListPlans.php b/src/Filament/Resources/PlanResource/Pages/ListPlans.php index 58f62a6..45e4ffc 100644 --- a/src/Filament/Resources/PlanResource/Pages/ListPlans.php +++ b/src/Filament/Resources/PlanResource/Pages/ListPlans.php @@ -3,10 +3,10 @@ namespace LaraZeus\Pontus\Filament\Resources\PlanResource\Pages; use Filament\Actions; -use Filament\Resources\Pages\ListRecords; +use LaraZeus\Chaos\Filament\ChaosResource\Pages\ChaosListRecords; use LaraZeus\Pontus\Filament\Resources\PlanResource; -class ListPlans extends ListRecords +class ListPlans extends ChaosListRecords { protected static string $resource = PlanResource::class; diff --git a/src/Models/Features.php b/src/Models/Features.php index 0c684f0..3d1a131 100644 --- a/src/Models/Features.php +++ b/src/Models/Features.php @@ -12,9 +12,9 @@ class Features extends Model public function getRows(): array { return [ - ['code' => 'users', 'label' => __('subscription.features.users')], - ['code' => 'certificates', 'label' => __('subscription.features.certificates')], - ['code' => 'cooperative_training', 'label' => __('subscription.features.cooperative_training')], + ['code' => 'users', 'label' => __('zeus-pontus::plan.features.users')], + ['code' => 'certificates', 'label' => __('zeus-pontus::plan.features.certificates')], + ['code' => 'cooperative_training', 'label' => __('zeus-pontus::plan.features.cooperative_training')], ]; } } diff --git a/src/Models/Intervals.php b/src/Models/Intervals.php index 2a2f4aa..023b462 100644 --- a/src/Models/Intervals.php +++ b/src/Models/Intervals.php @@ -12,11 +12,11 @@ class Intervals extends Model public function getRows(): array { return [ - ['name' => 'hour', 'label' => __('subscription.hour')], - ['name' => 'day', 'label' => __('subscription.day')], - ['name' => 'week', 'label' => __('subscription.week')], - ['name' => 'month', 'label' => __('subscription.month')], - ['name' => 'year', 'label' => __('subscription.year')], + ['name' => 'hour', 'label' => __('zeus-pontus::plan.hour')], + ['name' => 'day', 'label' => __('zeus-pontus::plan.day')], + ['name' => 'week', 'label' => __('zeus-pontus::plan.week')], + ['name' => 'month', 'label' => __('zeus-pontus::plan.month')], + ['name' => 'year', 'label' => __('zeus-pontus::plan.year')], ]; } } diff --git a/src/PontusServiceProvider.php b/src/PontusServiceProvider.php index 2927f2f..44ce65d 100644 --- a/src/PontusServiceProvider.php +++ b/src/PontusServiceProvider.php @@ -17,6 +17,7 @@ public function configurePackage(Package $package): void ->hasCommands([ InstallCommand::class, ]) + ->hasConfigFile() ->hasTranslations(); } }