From 65c56b6f41e34893d9220a9d57957db8cd8a9688 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 2 Sep 2024 21:47:00 +0500 Subject: [PATCH] translate --- ...8_31_151813_create_swiftpayments_table.php | 2 + .../Swiftpayment/Models/Swiftpayment.php | 1 - .../Concerns/SwiftpaymentFieldsForIndex.php | 66 +++++ .../Nova/Resources/NovaSwiftpayment.php | 233 ++++++++++-------- app/Repos/System/Nova/NovaMenuRepo.php | 3 +- lang/tk.json | 5 +- .../nova-simple-repeatable-field/en.json | 3 + .../nova-simple-repeatable-field/ru.json | 3 + .../nova-simple-repeatable-field/tk.json | 3 + 9 files changed, 216 insertions(+), 103 deletions(-) create mode 100644 app/Modules/Swiftpayment/Nova/Resources/Concerns/SwiftpaymentFieldsForIndex.php create mode 100644 lang/vendor/nova-simple-repeatable-field/en.json create mode 100644 lang/vendor/nova-simple-repeatable-field/ru.json create mode 100644 lang/vendor/nova-simple-repeatable-field/tk.json diff --git a/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php b/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php index c93b74e..d012974 100644 --- a/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php +++ b/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php @@ -13,6 +13,8 @@ return new class extends Migration { Schema::create('swift_payments', function (Blueprint $table) { $table->id(); + $table->string('unique_id')->nullable()->unique(); + $table->string('type')->nullable(); $table->string('passport_name')->nullable(); $table->string('passport_surname')->nullable(); diff --git a/app/Modules/Swiftpayment/Models/Swiftpayment.php b/app/Modules/Swiftpayment/Models/Swiftpayment.php index 94767e8..a3301c2 100644 --- a/app/Modules/Swiftpayment/Models/Swiftpayment.php +++ b/app/Modules/Swiftpayment/Models/Swiftpayment.php @@ -3,7 +3,6 @@ namespace App\Modules\Swiftpayment\Models; use App\Models\Branch\Branch; -use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Spatie\MediaLibrary\HasMedia; diff --git a/app/Modules/Swiftpayment/Nova/Resources/Concerns/SwiftpaymentFieldsForIndex.php b/app/Modules/Swiftpayment/Nova/Resources/Concerns/SwiftpaymentFieldsForIndex.php new file mode 100644 index 0000000..3dd880c --- /dev/null +++ b/app/Modules/Swiftpayment/Nova/Resources/Concerns/SwiftpaymentFieldsForIndex.php @@ -0,0 +1,66 @@ +hide(), + + Text::make(__('ID'), 'unique_id')->sortable(), + + Select::make(__('Ýüztutmanyň görnüşi'), 'type') + ->fullWidth() + ->searchable() + ->rules('required') + ->displayUsingLabels() + ->options(ApplicationTypes::applicationTypes()), + + DateTime::make(__('Created at'), 'created_at') + ->turkmenDateTime(), + + Select::make(__('Region'), 'region') + ->displayUsingLabels() + ->options(RegionRepo::values()) + ->canSeeWhen('isAdmin', $resource) + ->sortable(), + + BelongsTo::make(__('Branch'), 'branch', Branch::class) + ->canSeeWhen('isAdmin', $resource) + ->filterable() + ->sortable(), + + Text::make(__('Name'), 'passport_name'), + + Text::make(__('Surname'), 'passport_surname'), + + Text::make(__('Phone'), 'phone'), + + Badge::make(__('Status'), 'status') + ->map(OrderRepo::statusClasses()) + ->addTypes([ + 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', + ]) + ->labels(OrderRepo::statusValues()) + ->withIcons() + ->icons(OrderRepo::statusIcons()) + ->sortable(), + ]; + } +} diff --git a/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php b/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php index 52acd95..abecc44 100644 --- a/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php +++ b/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php @@ -4,20 +4,22 @@ namespace App\Modules\Swiftpayment\Nova\Resources; use App\Models\Branch\Branch; use App\Modules\Swiftpayment\Models\ApplicationTypes; -use App\Modules\Swiftpayment\Models\SwiftPaymentStatus; +use App\Modules\Swiftpayment\Nova\Resources\Concerns\SwiftpaymentFieldsForIndex; use App\Nova\Resource; +use App\Repos\Order\Card\CardOrderRepo; use App\Repos\Order\OrderRepo; use App\Repos\System\Nova\NovaRepo; use App\Repos\System\Settings\Legal\PassportRepo; use App\Repos\System\Settings\Location\RegionRepo; use Ebess\AdvancedNovaMediaLibrary\Fields\Files; +use Illuminate\Database\Eloquent\Model; use Laravel\Nova\Fields\Badge; use Laravel\Nova\Fields\Hidden; use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; -use Laravel\Nova\Fields\Trix; use Laravel\Nova\Http\Requests\NovaRequest; +use Laravel\Nova\Panel; use Nurmuhammet\NovaInputmask\NovaInputmask; use Outl1ne\NovaSimpleRepeatable\SimpleRepeatable; @@ -38,7 +40,7 @@ class NovaSwiftpayment extends Resource * * @var string */ - public static $title = 'id'; + public static $title = 'unique_id'; /** * The columns that should be searched. @@ -46,7 +48,7 @@ class NovaSwiftpayment extends Resource * @var array */ public static $search = [ - 'id', + 'unique_id', 'passport_name', 'passport_surname', 'phone', ]; /** @@ -54,7 +56,7 @@ class NovaSwiftpayment extends Resource */ public static function label(): string { - return __('Swiftpayments'); + return __('Swift payments'); } /** @@ -62,7 +64,26 @@ class NovaSwiftpayment extends Resource */ public static function singularLabel(): string { - return __('Swiftpayment'); + return __('Swift payment'); + } + + /** + * After resource created + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @param \Illuminate\Database\Eloquent\Model $model + */ + public static function afterCreate(NovaRequest $request, Model $model): void + { + $model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]); + } + + /** + * Get the fields for index. + */ + public function fieldsForIndex(): array + { + return SwiftpaymentFieldsForIndex::make($this); } /** @@ -74,117 +95,129 @@ class NovaSwiftpayment extends Resource public function fields(NovaRequest $request): array { return [ - ID::make('id')->sortable(), + ID::hidden('id'), - Hidden::make('user_id')->default(auth()->id()), + Hidden::make('user_id') + ->default(auth()->id()) + ->hideWhenUpdating(), - Select::make(__('Status'), 'status') - ->displayUsingLabels() - ->searchable() - ->options(OrderRepo::statusValues()) - ->default(OrderRepo::defaultStatus()) - ->fullWidth() - ->rules('required') - ->canSeeWhen('systemUser', $this), + new Panel(__('New :resource', ['resource' => $this->singularLabel()]), [ + Text::make(__('ID'), 'unique_id') + ->exceptOnForms(), - Select::make(__('Ýüztutmanyň görnüşi'), 'type') - ->fullWidth() - ->searchable() - ->rules('required') - ->displayUsingLabels() - ->options(ApplicationTypes::applicationTypes()), - - Select::make(__('Region'), 'region') - ->fullWidth() - ->displayUsingLabels() - ->searchable() - ->options(RegionRepo::values()) - ->default(RegionRepo::default()) - ->rules('required') - ->sortable(), - - Select::make(__('Branch'), 'branch_id') - ->fullWidth() - ->displayUsingLabels() - ->searchable() - ->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class)) - ->rules('required') - ->sortable(), - - Text::make('Pasportdaky ady', 'passport_name') - ->fullWidth() - ->rules('required', 'string', 'max:255'), - - Text::make('Pasportdaky familiýa', 'passport_surname') - ->fullWidth() - ->rules('required', 'string', 'max:255'), - - NovaInputmask::make('Telefon belgi', 'phone') - ->fullWidth() - ->phonenumber('TM') - ->rules('required', 'max:255') - ->hideFromIndex(), - - Text::make('Email', 'email') - ->fullWidth() - ->rules('required', 'max:255', 'email') - ->hideFromIndex(), - - Text::make('Ýaşaýan ýeriň salgysy', 'address') - ->fullWidth() - ->rules('required', 'string', 'max:255') - ->hideFromIndex(), - - SimpleRepeatable::make('Tölegi ugradyjynyň maglumatlar', 'sender_datas', [ - Select::make(__('Passport serie'), 'passport_serie') + Select::make(__('Status'), 'status') ->displayUsingLabels() ->searchable() - ->options(PassportRepo::values()) + ->options(OrderRepo::statusValues()) + ->default(OrderRepo::defaultStatus()) + ->fullWidth() + ->hideFromDetail() + ->rules('required') + ->canSeeWhen('systemUser', $this), + + Badge::make(__('Status'), 'status') + ->map(OrderRepo::statusClasses()) + ->addTypes([ + 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', + ]) + ->labels(OrderRepo::statusValues()) + ->withIcons() + ->icons(OrderRepo::statusIcons()), + + Text::make(__('Note'), 'notes') + ->fullWidth() + ->canSeeWhen('systemUser', $this), + ]), + + new Panel(__('Location'), [ + Select::make(__('Ýüztutmanyň görnüşi'), 'type') + ->fullWidth() + ->searchable() + ->rules('required') + ->displayUsingLabels() + ->options(ApplicationTypes::applicationTypes()), + + Select::make(__('Region'), 'region') + ->fullWidth() + ->displayUsingLabels() + ->searchable() + ->options(RegionRepo::values()) + ->default(RegionRepo::default()) ->rules('required') ->sortable(), - NovaInputmask::make('Passport nomeri') - ->mask('999999') - ->rules('required', 'max:255'), - - Text::make('A.F.AA'), - ])->minRows(1)->rules('required'), - - SimpleRepeatable::make('Tölegi kabul edijiniň maglumatlary', 'payment_reciever', [ - Select::make(__('Passport serie'), 'passport_serie') + Select::make(__('Branch'), 'branch_id') + ->fullWidth() ->displayUsingLabels() ->searchable() - ->options(PassportRepo::values()) + ->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class)) ->rules('required') ->sortable(), + ]), - NovaInputmask::make('Passport nomeri') - ->mask('999999') - ->rules('required', 'max:255'), + new Panel(__('Personal data'), [ + Text::make('Pasportdaky ady', 'passport_name') + ->fullWidth() + ->rules('required', 'string', 'max:255'), - Text::make('A.F.AA'), - ])->maxRows(1)->rules('required'), + Text::make('Pasportdaky familiýa', 'passport_surname') + ->fullWidth() + ->rules('required', 'string', 'max:255'), - Files::make('Talap edilýän resminamalar', 'main') - ->conversionOnIndexView('thumb') - ->rules('required') - ->hideFromIndex(), + NovaInputmask::make('Telefon belgi', 'phone') + ->fullWidth() + ->phonenumber('TM') + ->rules('required', 'max:255') + ->hideFromIndex(), - Badge::make(__('Status'), 'status') - ->map(OrderRepo::statusClasses()) - ->addTypes([ - 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', - ]) - ->labels(OrderRepo::statusValues()) - ->withIcons() - ->icons(OrderRepo::statusIcons()), + Text::make('Email', 'email') + ->fullWidth() + ->rules('required', 'max:255', 'email') + ->hideFromIndex(), - Trix::make(__('Notes'), 'notes') - ->hideWhenCreating() - ->alwaysShow() - ->readonly(function ($request) { - return ! $request->user()->hasRole(['admin', 'manager', 'operator']); - }), + Text::make('Ýaşaýan ýeriň salgysy', 'address') + ->fullWidth() + ->rules('required', 'string', 'max:255') + ->hideFromIndex(), + ]), + + new Panel(__('Töleg'), [ + SimpleRepeatable::make('Tölegi ugradyjynyň maglumatlar', 'sender_datas', [ + Select::make(__('Passport serie'), 'passport_serie') + ->displayUsingLabels() + ->searchable() + ->options(PassportRepo::values()) + ->rules('required') + ->sortable(), + + NovaInputmask::make('Passport nomeri') + ->mask('999999') + ->rules('required', 'max:255'), + + Text::make('A.F.AA'), + ])->minRows(1)->rules('required'), + + SimpleRepeatable::make('Tölegi kabul edijiniň maglumatlary', 'payment_reciever', [ + Select::make(__('Passport serie'), 'passport_serie') + ->displayUsingLabels() + ->searchable() + ->options(PassportRepo::values()) + ->rules('required') + ->sortable(), + + NovaInputmask::make('Passport nomeri') + ->mask('999999') + ->rules('required', 'max:255'), + + Text::make('A.F.AA'), + ])->maxRows(1)->minRows(1)->rules('required'), + + Files::make('Talap edilýän resminamalar', 'main') + ->conversionOnIndexView('thumb') + ->rules('required') + ->required() + ->hideFromIndex(), + ]), ]; } } diff --git a/app/Repos/System/Nova/NovaMenuRepo.php b/app/Repos/System/Nova/NovaMenuRepo.php index dd01ead..3728883 100644 --- a/app/Repos/System/Nova/NovaMenuRepo.php +++ b/app/Repos/System/Nova/NovaMenuRepo.php @@ -50,7 +50,8 @@ class NovaMenuRepo ])->collapsedByDefault(), MenuGroup::make(__('Swift payments'), [ - MenuItem::resource(NovaSwiftpayment::class), + MenuItem::resource(NovaSwiftpayment::class) + ->name(sprintf('%s (%s)', __('International payments'), __('Visa, Master, Sber, WU'))), ])->collapsedByDefault(), ])->icon('ticket')->collapsedByDefault(), diff --git a/lang/tk.json b/lang/tk.json index 08e5af2..b2e3ec5 100644 --- a/lang/tk.json +++ b/lang/tk.json @@ -284,5 +284,8 @@ "Client": "Müşderi", "Successfully registered": "Üstünlikli hasaba alyndyňyz", "Please, now verify your phone number to continue": "Dowam etmek üçin telefon belgiňizi tassyklaň", - "Swift payments": "Swift tölegler" + "Swift payments": "Swift tölegler", + "Swift payment": "Swift töleg", + "International payments": "Halkara tölegler", + "Visa, Master, Sber, WU": "Visa, Master, Sber, WU" } diff --git a/lang/vendor/nova-simple-repeatable-field/en.json b/lang/vendor/nova-simple-repeatable-field/en.json new file mode 100644 index 0000000..293f5a0 --- /dev/null +++ b/lang/vendor/nova-simple-repeatable-field/en.json @@ -0,0 +1,3 @@ +{ + "simpleRepeatable.addRow": "Add row" +} diff --git a/lang/vendor/nova-simple-repeatable-field/ru.json b/lang/vendor/nova-simple-repeatable-field/ru.json new file mode 100644 index 0000000..89f25c2 --- /dev/null +++ b/lang/vendor/nova-simple-repeatable-field/ru.json @@ -0,0 +1,3 @@ +{ + "simpleRepeatable.addRow": "Добавить строку" +} diff --git a/lang/vendor/nova-simple-repeatable-field/tk.json b/lang/vendor/nova-simple-repeatable-field/tk.json new file mode 100644 index 0000000..514a211 --- /dev/null +++ b/lang/vendor/nova-simple-repeatable-field/tk.json @@ -0,0 +1,3 @@ +{ + "simpleRepeatable.addRow": "Setir goş" +}