diff --git a/app/Models/CurrencyRate.php b/app/Models/CurrencyRate.php new file mode 100644 index 0000000..e59b372 --- /dev/null +++ b/app/Models/CurrencyRate.php @@ -0,0 +1,192 @@ + 'AED', + 'AFN' => 'AFN', + 'ALL' => 'ALL', + 'AMD' => 'AMD', + 'ANG' => 'ANG', + 'AOA' => 'AOA', + 'ARS' => 'ARS', + 'AUD' => 'AUD', + 'AWG' => 'AWG', + 'AZN' => 'AZN', + 'BAM' => 'BAM', + 'BBD' => 'BBD', + 'BDT' => 'BDT', + 'BGN' => 'BGN', + 'BHD' => 'BHD', + 'BIF' => 'BIF', + 'BMD' => 'BMD', + 'BND' => 'BND', + 'BOB' => 'BOB', + 'BRL' => 'BRL', + 'BSD' => 'BSD', + 'BTN' => 'BTN', + 'BWP' => 'BWP', + 'BYN' => 'BYN', + 'BZD' => 'BZD', + 'CAD' => 'CAD', + 'CDF' => 'CDF', + 'CHF' => 'CHF', + 'CKD' => 'CKD', + 'CLP' => 'CLP', + 'CNY' => 'CNY', + 'COP' => 'COP', + 'CRC' => 'CRC', + 'CUC' => 'CUC', + 'CUP' => 'CUP', + 'CVE' => 'CVE', + 'CZK' => 'CZK', + 'DJF' => 'DJF', + 'DKK' => 'DKK', + 'DOP' => 'DOP', + 'DZD' => 'DZD', + 'EGP' => 'EGP', + 'EHP' => 'EHP', + 'ERN' => 'ERN', + 'ETB' => 'ETB', + 'EUR' => 'EUR', + 'FJD' => 'FJD', + 'FKP' => 'FKP', + 'FOK' => 'FOK', + 'GBP' => 'GBP', + 'GEL' => 'GEL', + 'GGP' => 'GGP', + 'GHS' => 'GHS', + 'GIP' => 'GIP', + 'GMD' => 'GMD', + 'GNF' => 'GNF', + 'GTQ' => 'GTQ', + 'GYD' => 'GYD', + 'HKD' => 'HKD', + 'HNL' => 'HNL', + 'HRK' => 'HRK', + 'HTG' => 'HTG', + 'HUF' => 'HUF', + 'IDR' => 'IDR', + 'ILS' => 'ILS', + 'IMP' => 'IMP', + 'INR' => 'INR', + 'IQD' => 'IQD', + 'IRR' => 'IRR', + 'ISK' => 'ISK', + 'JEP' => 'JEP', + 'JMD' => 'JMD', + 'JOD' => 'JOD', + 'JPY' => 'JPY', + 'KES' => 'KES', + 'KGS' => 'KGS', + 'KHR' => 'KHR', + 'KID' => 'KID', + 'KMF' => 'KMF', + 'KPW' => 'KPW', + 'KRW' => 'KRW', + 'KWD' => 'KWD', + 'KYD' => 'KYD', + 'KZT' => 'KZT', + 'LAK' => 'LAK', + 'LBP' => 'LBP', + 'LKR' => 'LKR', + 'LRD' => 'LRD', + 'LSL' => 'LSL', + 'LYD' => 'LYD', + 'MAD' => 'MAD', + 'MDL' => 'MDL', + 'MGA' => 'MGA', + 'MKD' => 'MKD', + 'MMK' => 'MMK', + 'MNT' => 'MNT', + 'MOP' => 'MOP', + 'MRU' => 'MRU', + 'MUR' => 'MUR', + 'MVR' => 'MVR', + 'MWK' => 'MWK', + 'MXN' => 'MXN', + 'MYR' => 'MYR', + 'MZN' => 'MZN', + 'NAD' => 'NAD', + 'NGN' => 'NGN', + 'NIO' => 'NIO', + 'NOK' => 'NOK', + 'NPR' => 'NPR', + 'NZD' => 'NZD', + 'OMR' => 'OMR', + 'PAB' => 'PAB', + 'PEN' => 'PEN', + 'PGK' => 'PGK', + 'PHP' => 'PHP', + 'PKR' => 'PKR', + 'PLN' => 'PLN', + 'PND' => 'PND', + 'PRB' => 'PRB', + 'PYG' => 'PYG', + 'QAR' => 'QAR', + 'RON' => 'RON', + 'RSD' => 'RSD', + 'RUB' => 'RUB', + 'RWF' => 'RWF', + 'SAR' => 'SAR', + 'SBD' => 'SBD', + 'SCR' => 'SCR', + 'SDG' => 'SDG', + 'SEK' => 'SEK', + 'SGD' => 'SGD', + 'SHP' => 'SHP', + 'SLL' => 'SLL', + 'SLS' => 'SLS', + 'SOS' => 'SOS', + 'SRD' => 'SRD', + 'SSP' => 'SSP', + 'STN' => 'STN', + 'SVC' => 'SVC', + 'SYP' => 'SYP', + 'SZL' => 'SZL', + 'THB' => 'THB', + 'TJS' => 'TJS', + 'TMT' => 'TMT', + 'TND' => 'TND', + 'TOP' => 'TOP', + 'TRY' => 'TRY', + 'TTD' => 'TTD', + 'TVD' => 'TVD', + 'TWD' => 'TWD', + 'TZS' => 'TZS', + 'UAH' => 'UAH', + 'UGX' => 'UGX', + 'USD' => 'USD', + 'UYU' => 'UYU', + 'UZS' => 'UZS', + 'VED' => 'VED', + 'VES' => 'VES', + 'VND' => 'VND', + 'VUV' => 'VUV', + 'WST' => 'WST', + 'XAF' => 'XAF', + 'XCD' => 'XCD', + 'XOF' => 'XOF', + 'XPF' => 'XPF', + 'YER' => 'YER', + 'ZAR' => 'ZAR', + 'ZMW' => 'ZMW', + 'ZWB' => 'ZWB', + 'ZWL' => 'ZWL', + 'Abkhazia' => 'Abkhazia', + 'Artsakh' => 'Artsakh', + ]; + } +} diff --git a/app/Nova/Actions/MakePaymentNovaVisaMaster.php b/app/Nova/Actions/MakePaymentNovaVisaMaster.php index f70f78d..3ae2a1b 100644 --- a/app/Nova/Actions/MakePaymentNovaVisaMaster.php +++ b/app/Nova/Actions/MakePaymentNovaVisaMaster.php @@ -12,13 +12,21 @@ use Illuminate\Support\Facades\Log; use Laravel\Nova\Actions\Action; use Laravel\Nova\Actions\ActionResponse; use Laravel\Nova\Fields\ActionFields; -use Laravel\Nova\Fields\Select; +use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; class MakePaymentNovaVisaMaster extends Action { use InteractsWithQueue, Queueable; + /** + * Action name + */ + public function name(): string + { + return __('Send payment'); + } + /** * Perform the action on the given models. * @@ -30,12 +38,12 @@ class MakePaymentNovaVisaMaster extends Action { $resource = $models->first(); - $payment = $this->order($resource, $fields->payment_method); - - if (! $resource->branch) { + if (! $resource->branch || ! $resource->branch->billing_visa_master_username) { return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.'); } + $payment = $this->order($resource, $fields->payment_method); + return $payment['status'] === 'success' ? ActionResponse::openInNewTab($payment['url']) : ActionResponse::danger('Töleg ýerinde näsazlyk!'); @@ -50,15 +58,10 @@ class MakePaymentNovaVisaMaster extends Action public function fields(NovaRequest $request): array { return [ - Select::make(__('Select payment method'), 'payment_method') - ->displayUsingLabels() - ->searchable() - ->options([ - 'usd' => __('USD'), - 'rubl' => __('RUBL'), - ]) - ->rules('required') - ->fullWidth(), + Text::make(__('Töleg möçberi'), 'payment_amount') + ->fullWidth() + ->required() + ->rules('required', 'rules:250'), ]; } @@ -73,7 +76,7 @@ class MakePaymentNovaVisaMaster extends Action $paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [ 'orderNumber' => $orderNumber, - 'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '902.38' : '1058,60'), + 'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '90238' : '105860'), 'currency' => 934, 'language' => 'ru', 'userName' => $resource->branch->billing_username, diff --git a/app/Nova/Resources/CurrencyRate.php b/app/Nova/Resources/CurrencyRate.php new file mode 100644 index 0000000..139dafc --- /dev/null +++ b/app/Nova/Resources/CurrencyRate.php @@ -0,0 +1,115 @@ + + */ + public static $model = \App\Models\CurrencyRate::class; + + /** + * The single value that should be used to represent the resource when being displayed. + * + * @var string + */ + public static $title = 'id'; + + /** + * The columns that should be searched. + * + * @var array + */ + public static $search = [ + 'id', + ]; + + /** + * Get the fields displayed by the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function fields(NovaRequest $request) + { + return [ + ID::make()->sortable(), + + Select::make(__('Currency from'), 'currency_from') + ->displayUsingLabels() + ->searchable() + ->options(ModelsCurrencyRate::currencies()) + ->rules('required') + ->fullWidth() + ->help('1 möçberi'), + + Select::make(__('Currency to'), 'currency_to') + ->displayUsingLabels() + ->searchable() + ->options(ModelsCurrencyRate::currencies()) + ->rules('required') + ->fullWidth(), + + Text::make('Value', 'value') + ->fullWidth() + ->rules('required', 'numeric'), + ]; + } + + /** + * Get the cards available for the request. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function cards(NovaRequest $request) + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function filters(NovaRequest $request) + { + return []; + } + + /** + * Get the lenses available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function lenses(NovaRequest $request) + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function actions(NovaRequest $request) + { + return []; + } +} diff --git a/app/Repos/System/Nova/NovaMenuRepo.php b/app/Repos/System/Nova/NovaMenuRepo.php index 0961d26..78e2eb0 100644 --- a/app/Repos/System/Nova/NovaMenuRepo.php +++ b/app/Repos/System/Nova/NovaMenuRepo.php @@ -7,6 +7,7 @@ use App\Modules\TuitionPaymentOrder\Nova\Resources\NovaTuitionPaymentOrder; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\NovaVisaMasterPaymentOrder; use App\Nova\Dashboards\Main; use App\Nova\Resources\Branch\Branch; +use App\Nova\Resources\CurrencyRate; use App\Nova\Resources\Order\Card\CardOrder; use App\Nova\Resources\Order\Card\CardState; use App\Nova\Resources\Order\Card\CardType; @@ -87,6 +88,10 @@ class NovaMenuRepo MenuItem::resource(Branch::class), ])->collapsedByDefault(), + MenuGroup::make(__('Currencies'), [ + MenuItem::resource(CurrencyRate::class), + ])->collapsedByDefault(), + MenuGroup::make(__('Locale'), [ MenuItem::resource(LocaleManagerResource::class), ])->collapsedByDefault(), diff --git a/database/migrations/2024_10_14_102130_create_currency_rates_table.php b/database/migrations/2024_10_14_102130_create_currency_rates_table.php new file mode 100644 index 0000000..f96c459 --- /dev/null +++ b/database/migrations/2024_10_14_102130_create_currency_rates_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('currency_from'); + $table->string('currency_to'); + $table->string('value'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('currency_rates'); + } +}; diff --git a/lang/tk.json b/lang/tk.json index 236baf1..6c54796 100644 --- a/lang/tk.json +++ b/lang/tk.json @@ -318,5 +318,7 @@ "Sber payments": "Sber tölegler", "Sber payment": "Sber töleg", "Select payment method": "Töleg görnüşini saýlaň", - "Loan Card": "Karz karty" + "Loan Card": "Karz karty", + "Send payment": "Tölegi geçir", + "Currencies": "Walýutalar" } diff --git a/resources/currencies.json b/resources/currencies.json new file mode 100644 index 0000000..2235aa5 --- /dev/null +++ b/resources/currencies.json @@ -0,0 +1 @@ +["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CKD","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","EHP","ERN","ETB","EUR","FJD","FKP","FOK","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KID","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PND","PRB","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SLS","SOS","SRD","SSP","STN","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TVD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VED","VES","VND","VUV","WST","XAF","XCD","XOF","XPF","YER","ZAR","ZMW","ZWB","ZWL","Abkhazia","Artsakh"] \ No newline at end of file