Currency rates
This commit is contained in:
192
app/Models/CurrencyRate.php
Normal file
192
app/Models/CurrencyRate.php
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CurrencyRate extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currencies
|
||||||
|
*/
|
||||||
|
public static function currencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'AED' => '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',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,13 +12,21 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use Laravel\Nova\Actions\Action;
|
use Laravel\Nova\Actions\Action;
|
||||||
use Laravel\Nova\Actions\ActionResponse;
|
use Laravel\Nova\Actions\ActionResponse;
|
||||||
use Laravel\Nova\Fields\ActionFields;
|
use Laravel\Nova\Fields\ActionFields;
|
||||||
use Laravel\Nova\Fields\Select;
|
use Laravel\Nova\Fields\Text;
|
||||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
class MakePaymentNovaVisaMaster extends Action
|
class MakePaymentNovaVisaMaster extends Action
|
||||||
{
|
{
|
||||||
use InteractsWithQueue, Queueable;
|
use InteractsWithQueue, Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action name
|
||||||
|
*/
|
||||||
|
public function name(): string
|
||||||
|
{
|
||||||
|
return __('Send payment');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the action on the given models.
|
* Perform the action on the given models.
|
||||||
*
|
*
|
||||||
@@ -30,12 +38,12 @@ class MakePaymentNovaVisaMaster extends Action
|
|||||||
{
|
{
|
||||||
$resource = $models->first();
|
$resource = $models->first();
|
||||||
|
|
||||||
$payment = $this->order($resource, $fields->payment_method);
|
if (! $resource->branch || ! $resource->branch->billing_visa_master_username) {
|
||||||
|
|
||||||
if (! $resource->branch) {
|
|
||||||
return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.');
|
return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$payment = $this->order($resource, $fields->payment_method);
|
||||||
|
|
||||||
return $payment['status'] === 'success'
|
return $payment['status'] === 'success'
|
||||||
? ActionResponse::openInNewTab($payment['url'])
|
? ActionResponse::openInNewTab($payment['url'])
|
||||||
: ActionResponse::danger('Töleg ýerinde näsazlyk!');
|
: ActionResponse::danger('Töleg ýerinde näsazlyk!');
|
||||||
@@ -50,15 +58,10 @@ class MakePaymentNovaVisaMaster extends Action
|
|||||||
public function fields(NovaRequest $request): array
|
public function fields(NovaRequest $request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Select::make(__('Select payment method'), 'payment_method')
|
Text::make(__('Töleg möçberi'), 'payment_amount')
|
||||||
->displayUsingLabels()
|
->fullWidth()
|
||||||
->searchable()
|
->required()
|
||||||
->options([
|
->rules('required', 'rules:250'),
|
||||||
'usd' => __('USD'),
|
|
||||||
'rubl' => __('RUBL'),
|
|
||||||
])
|
|
||||||
->rules('required')
|
|
||||||
->fullWidth(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +76,7 @@ class MakePaymentNovaVisaMaster extends Action
|
|||||||
|
|
||||||
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
|
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
|
||||||
'orderNumber' => $orderNumber,
|
'orderNumber' => $orderNumber,
|
||||||
'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '902.38' : '1058,60'),
|
'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '90238' : '105860'),
|
||||||
'currency' => 934,
|
'currency' => 934,
|
||||||
'language' => 'ru',
|
'language' => 'ru',
|
||||||
'userName' => $resource->branch->billing_username,
|
'userName' => $resource->branch->billing_username,
|
||||||
|
|||||||
115
app/Nova/Resources/CurrencyRate.php
Normal file
115
app/Nova/Resources/CurrencyRate.php
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources;
|
||||||
|
|
||||||
|
use App\Models\CurrencyRate as ModelsCurrencyRate;
|
||||||
|
use App\Nova\Resource;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laravel\Nova\Fields\Currency;
|
||||||
|
use Laravel\Nova\Fields\ID;
|
||||||
|
use Laravel\Nova\Fields\Number;
|
||||||
|
use Laravel\Nova\Fields\Select;
|
||||||
|
use Laravel\Nova\Fields\Text;
|
||||||
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
|
class CurrencyRate extends Resource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model the resource corresponds to.
|
||||||
|
*
|
||||||
|
* @var class-string<\App\Models\CurrencyRate>
|
||||||
|
*/
|
||||||
|
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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ use App\Modules\TuitionPaymentOrder\Nova\Resources\NovaTuitionPaymentOrder;
|
|||||||
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\NovaVisaMasterPaymentOrder;
|
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\NovaVisaMasterPaymentOrder;
|
||||||
use App\Nova\Dashboards\Main;
|
use App\Nova\Dashboards\Main;
|
||||||
use App\Nova\Resources\Branch\Branch;
|
use App\Nova\Resources\Branch\Branch;
|
||||||
|
use App\Nova\Resources\CurrencyRate;
|
||||||
use App\Nova\Resources\Order\Card\CardOrder;
|
use App\Nova\Resources\Order\Card\CardOrder;
|
||||||
use App\Nova\Resources\Order\Card\CardState;
|
use App\Nova\Resources\Order\Card\CardState;
|
||||||
use App\Nova\Resources\Order\Card\CardType;
|
use App\Nova\Resources\Order\Card\CardType;
|
||||||
@@ -87,6 +88,10 @@ class NovaMenuRepo
|
|||||||
MenuItem::resource(Branch::class),
|
MenuItem::resource(Branch::class),
|
||||||
])->collapsedByDefault(),
|
])->collapsedByDefault(),
|
||||||
|
|
||||||
|
MenuGroup::make(__('Currencies'), [
|
||||||
|
MenuItem::resource(CurrencyRate::class),
|
||||||
|
])->collapsedByDefault(),
|
||||||
|
|
||||||
MenuGroup::make(__('Locale'), [
|
MenuGroup::make(__('Locale'), [
|
||||||
MenuItem::resource(LocaleManagerResource::class),
|
MenuItem::resource(LocaleManagerResource::class),
|
||||||
])->collapsedByDefault(),
|
])->collapsedByDefault(),
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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('currency_rates', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -318,5 +318,7 @@
|
|||||||
"Sber payments": "Sber tölegler",
|
"Sber payments": "Sber tölegler",
|
||||||
"Sber payment": "Sber töleg",
|
"Sber payment": "Sber töleg",
|
||||||
"Select payment method": "Töleg görnüşini saýlaň",
|
"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"
|
||||||
}
|
}
|
||||||
|
|||||||
1
resources/currencies.json
Normal file
1
resources/currencies.json
Normal file
@@ -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"]
|
||||||
Reference in New Issue
Block a user