Currency rates
This commit is contained in:
@@ -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,
|
||||
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user