From 0939b59ec38a683ad74d6b0cbfbee04dd92bf732 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Thu, 5 Sep 2024 16:27:58 +0500 Subject: [PATCH] wip on visa/master payment --- .../Models/VisaMasterPaymentOrder.php | 103 +++++++++-- .../Resources/NovaVisaMasterPaymentOrder.php | 23 ++- .../VisaMasterPaymentOrderFileFields.php | 45 +++++ index.html | 42 +++++ resources/js/vendor/nova/js/additional.js | 168 ++++++++++++++++++ resources/views/vendor/nova/layout.blade.php | 60 +++++++ 6 files changed, 415 insertions(+), 26 deletions(-) create mode 100644 app/Modules/VisaMasterPaymentOrder/Nova/Resources/VisaMasterPaymentOrderFileFields.php create mode 100644 index.html create mode 100644 resources/views/vendor/nova/layout.blade.php diff --git a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php index 563cc8c..af0e91c 100644 --- a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php +++ b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php @@ -35,24 +35,18 @@ class VisaMasterPaymentOrder extends Model implements HasMedia 'payment_reciever' => 'array', ]; - /** - * Media conversions - * - * @param Media|null $media - */ - public function registerMediaConversions(?Media $media = null): void - { - $this->addMediaConversion('thumb') - ->width(200) - ->height(200); - } - /** * Media collections */ public function registerMediaCollections(): void { - $this->addMediaCollection('main'); + foreach (static::reciverFiles() as $reciverFile) { + $this->addMediaCollection($reciverFile['code'])->singleFile(); + } + + foreach (static::senderFiles() as $senderFile) { + $this->addMediaCollection($senderFile['code'])->singleFile(); + } } /** @@ -73,4 +67,87 @@ class VisaMasterPaymentOrder extends Model implements HasMedia 'master' => __('Master'), ]; } + + /** + * Required files + */ + public static function reciverFiles(): array + { + return [ + [ + 'required' => true, + 'code' => 'requisite', + 'name' => 'Talyba degişli walýuta “VISA” kartyň rekwizitleri', + ], + [ + 'required' => false, + 'code' => 'document_stating_he_is_studying', + 'name' => 'Talybyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy', + ], + [ + 'required' => false, + 'code' => 'passport_local', + 'name' => 'Talyba degişli Türkmenistanyň raýatynyň (içki milli) pasportynyň asyl görnüşi we göçürmesi', + ], + [ + 'required' => false, + 'code' => 'passport_international', + 'name' => 'Talybyň Türkmenistandan çykmak we Türkmenistana girmek üçin (zagran) pasportynyň göçürmesi', + ], + [ + 'required' => false, + 'code' => 'visa', + 'name' => 'Talybyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportyndaky daşary ýurtda galyp okap bilýändigi baradaky berlen möhleti hereket edýän rugsatnamasynyň (wizasynyň) bellenen sahypasynyň göçürmesi', + ], + [ + 'required' => false, + 'code' => 'travel_stamp_on_passport', + 'name' => 'Talybyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportyndaky Türkmenistandan çykandygy we daşary ýurt döwletine girendigi baradaky ştamplaryň (seneli ştampyň) bellenen sahypasynyň göçürmesi', + ], + [ + 'required' => false, + 'code' => 'document_stating_he_is_studying_2', + 'name' => 'Talybyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasyndaky maglumatyň doly takyk däl ýagdaýynda takyk däl maglumatyň sebäpleri baradaky daşary ýurt döwletiniň ýokary okuw mekdebinden haty', + ], + ]; + } + + /** + * Sender files + */ + public static function senderFiles(): array + { + return [ + [ + 'required' => true, + 'code' => 'passport_local', + 'name' => 'ugradyja degişli Türkmenistanyň raýatynyň (içki milli) pasportynyň asyl görnüşi we göçürmesi', + ], + [ + 'required' => false, + 'code' => 'passport_international', + 'name' => 'ugradyja degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň asyl görnüşi we göçürmesi', + ], + [ + 'required' => false, + 'code' => 'travel_stamp_on_passport', + 'name' => 'ugradyja degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportyndaky daşary döwletine gidendigi we daşary döwlete barandygy baradaky (ştampyň) bellenen sahypasynyň göçürmesi', + ], + [ + 'required' => true, + 'code' => 'proof_of_kinship', + 'name' => 'ugradyjynyň we kabul edijiniň (talybyň) özara garyndaşlyk derejesini tassyklaýjy resminamalarynyň göçürmesi', + ], + [ + 'required' => false, + 'code' => 'passport_local_old', + 'name' => 'ugradyjy we kabul ediji (talyp) 2015-nji ýyldan soňra Türkmenistanyň raýatynyň pasportyny ikinji gezek alan bolsa, onda birinji gezek alan pasportynyň seriýasy baradaky maglumat', + ], + [ + 'required' => false, + 'code' => 'passport_local_old_replacement', + 'name' => 'ugradyjy we kabul ediji (talyp) 2015-nji ýyldan soňra Türkmenistanyň raýatynyň pasportyny ikinji gezek alandan soňra birinji gezek alan pasportynyň seriýasy baradaky maglumaty bilmeýän ,bolsa onda polisiýanyň degişli edaralaryndan birinji alan pasportynyň seriýasy baradaky güwänamasy', + ], + ]; + } } diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php index df7a2bb..a3bbf82 100644 --- a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php @@ -11,7 +11,6 @@ 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 Illuminate\Support\Str; use Laravel\Nova\Fields\Badge; @@ -104,13 +103,14 @@ class NovaVisaMasterPaymentOrder extends Resource public function fields(NovaRequest $request): array { return [ - ID::hidden(), - - Hidden::make('user_id') - ->default(auth()->id()) - ->hideWhenUpdating(), - new Panel(__('New :resource', ['resource' => $this->singularLabel()]), [ + ID::make() + ->hideFromDetail(), + + Hidden::make('user_id') + ->default(auth()->id()) + ->hideWhenUpdating(), + Text::make(__('ID'), 'unique_id') ->exceptOnForms(), @@ -229,13 +229,10 @@ class NovaVisaMasterPaymentOrder extends Resource attribute: 'full_name' ), ])->maxRows(1)->minRows(1)->rules('required'), - - Files::make('Talap edilýän resminamalar', 'main') - ->conversionOnIndexView('thumb') - ->rules('required') - ->required() - ->hideFromIndex(), ]), + + // new Panel(__('Reciver files'), VisaMasterPaymentOrderFileFields::reciverFiles()), + // new Panel(__('Sender files'), VisaMasterPaymentOrderFileFields::senderFiles()), ]; } } diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/VisaMasterPaymentOrderFileFields.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/VisaMasterPaymentOrderFileFields.php new file mode 100644 index 0000000..77dbef3 --- /dev/null +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/VisaMasterPaymentOrderFileFields.php @@ -0,0 +1,45 @@ +map(fn (array $file) => Files::make(__($file['name']), $file['code']) + ->size('w-1/2') + ->rules($file['required'] ? 'required' : 'nullable') + ->required($file['required']) + ) + ->toArray(); + } + + /** + * Sender files + */ + public static function senderFiles(): array + { + return collect(VisaMasterPaymentOrder::senderFiles()) + ->map(fn (array $file) => Files::make(__($file['name']), $file['code']) + ->size('w-1/2') + ->rules($file['required'] ? 'required' : 'nullable') + ->required($file['required']) + ) + ->toArray(); + } +} + +// File::make(__($file['name']), $file['code']) +// ->size('w-1/2') +// ->deletable(false) +// ->rules('max:2048', 'mimes:jpg,png,jpeg') +// ->creationRules($file['required'] ? 'required' : 'nullable') +// ->updateRules('nullable') diff --git a/index.html b/index.html new file mode 100644 index 0000000..fd604d4 --- /dev/null +++ b/index.html @@ -0,0 +1,42 @@ +
+
+

Step {{ index + 1 }}

+
+ + + +
+
+ + + diff --git a/resources/js/vendor/nova/js/additional.js b/resources/js/vendor/nova/js/additional.js index e69de29..56d897a 100644 --- a/resources/js/vendor/nova/js/additional.js +++ b/resources/js/vendor/nova/js/additional.js @@ -0,0 +1,168 @@ +// window.LaravelNovaWizardStore = { +// data: { +// steps: 0, +// currentStep: 1, +// }, + +// fields: { +// buttonsContainerElement: {}, +// cancelFormButton: {}, +// createFormButton: {}, +// prevButtonElement: {}, +// nextButtonElement: {}, +// }, + +// nextStep() { +// if (this.data.steps > 0 && this.data.currentStep < this.data.steps) { +// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'none'; + +// this.data.currentStep++; + +// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'inherit'; + +// return; +// } + +// if (this.data.currentStep === this.data.steps) { +// this.hideNextButton() +// this.showFormSubmitButton() +// } else { +// this.hideFormSubmitButton() +// this.showNextButton() +// } +// }, + +// prevStep() { +// if (this.data.currentStep > 1) { +// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'none'; + +// this.data.currentStep--; + +// document.querySelector(`div[wizard-step="${this.data.currentStep}"]`).style.display = 'inherit'; +// } +// }, + +// hideNovaFormButtons() { +// this.fields.cancelFormButton = document.querySelector('button[dusk="cancel-create-button"]'); +// this.fields.createFormButton = document.querySelector('button[dusk="create-button"]'); + +// this.fields.buttonsContainerElement = this.fields.createFormButton.parentNode; +// this.hideFormSubmitButton(); +// this.hideFormCancelButton(); +// }, + +// addWizardButtons() { +// this.fields.buttonsContainerElement.insertAdjacentHTML('afterbegin', this.nextButtonTemplate()); +// this.fields.buttonsContainerElement.insertAdjacentHTML('afterbegin', this.prevButtonTemplate()); + +// this.fields.nextButtonElement = document.getElementById('laravel-nova-wizard-next-button'); +// this.fields.prevButtonElement = document.getElementById('laravel-nova-wizard-prev-button'); + +// this.fields.nextButtonElement.addEventListener('click', () => { +// this.nextStep() +// }) + +// this.fields.prevButtonElement.addEventListener('click', () => { +// this.prevStep() +// }) +// }, + +// nextButtonTemplate() { +// return ` +// +// `; +// }, + +// prevButtonTemplate() { +// return ` +// +// `; +// }, + +// hidePrevButton() { +// this.fields.prevButtonElement.style.display = 'none' +// }, + +// showPrevButton() { +// this.fields.prevButtonElement.style.display = 'inherit' +// }, + +// hideNextButton() { +// this.fields.nextButtonElement.style.display = 'none' +// }, + +// showNextButton() { +// this.fields.nextButtonElement.style.display = 'inherit' +// }, + +// showFormSubmitButton() { +// this.fields.createFormButton.style.display = 'inherit'; +// }, + +// hideFormSubmitButton() { +// this.fields.createFormButton.style.display = 'none'; +// }, + +// hideFormCancelButton() { +// this.fields.cancelFormButton.style.display = 'none'; +// } +// }; + +// function setupMultiStepWizard() { +// let refreshIntervalId = setInterval(() => { +// let formElement = document.querySelector('form'); + +// if (formElement) { +// clearInterval(refreshIntervalId) + +// // Div container +// let fieldsContainerElement = formElement.firstChild; +// // Div elements +// let fieldElements = Array.from(fieldsContainerElement.children); + +// // if there a less than 2 divs, no need to wizard it! +// if (fieldElements.length < 2) { +// return; +// } + +// LaravelNovaWizardStore.data.steps = fieldElements.length; +// LaravelNovaWizardStore.hideNovaFormButtons() +// LaravelNovaWizardStore.addWizardButtons() + +// let loopCount = 0; +// fieldElements.forEach(item => { +// loopCount++; +// item.setAttribute('wizard-step', loopCount) + +// if (loopCount === 1) { +// return; +// } + +// item.style.display = 'none' +// }) +// } +// }, 300); +// } + +// Nova.$on('liftedOff', () => { +// if (Nova.$router.page.component === 'Nova.Create') { +// setupMultiStepWizard() +// } +// }) + +// Nova.$router.on('success', (event) => { +// if (event.detail.page.component === 'Nova.Create') { +// setupMultiStepWizard() +// } +// }) + +// document.addEventListener('inertia:navigate', () => { +// console.log('page is updating') +// }) + +// when app is booting +// Nova.booting((app, store) => {}) diff --git a/resources/views/vendor/nova/layout.blade.php b/resources/views/vendor/nova/layout.blade.php new file mode 100644 index 0000000..c7eb5ef --- /dev/null +++ b/resources/views/vendor/nova/layout.blade.php @@ -0,0 +1,60 @@ + + + + + + + + + + + @include('nova::partials.meta') + + + + + @if ($styles = \Laravel\Nova\Nova::availableStyles(request())) + + @foreach($styles as $asset) + + @endforeach + @endif + + + + + @inertia + + + + + + + + + + @if ($scripts = \Laravel\Nova\Nova::availableScripts(request())) + + @foreach ($scripts as $asset) + + @endforeach + @endif + + + + +