wip
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Nova\Actions;
|
namespace App\Nova\Actions;
|
||||||
|
|
||||||
|
use App\Models\CurrencyRate;
|
||||||
use App\Models\Payment\OnlinePaymentHistory;
|
use App\Models\Payment\OnlinePaymentHistory;
|
||||||
use App\Repos\Payment\OnlinePaymentRepo;
|
use App\Repos\Payment\OnlinePaymentRepo;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
@@ -12,6 +13,7 @@ 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\Heading;
|
||||||
use Laravel\Nova\Fields\Text;
|
use Laravel\Nova\Fields\Text;
|
||||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
@@ -57,11 +59,29 @@ class MakePaymentNovaVisaMaster extends Action
|
|||||||
*/
|
*/
|
||||||
public function fields(NovaRequest $request): array
|
public function fields(NovaRequest $request): array
|
||||||
{
|
{
|
||||||
|
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
|
||||||
|
|
||||||
|
$max_value = number_format($usd_to_tmt->value * 250, 2);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Text::make(__('Töleg möçberi'), 'payment_amount')
|
Heading::make('1 USD = ' . $usd_to_tmt->value . ' TMT'),
|
||||||
|
|
||||||
|
Text::make(sprintf('%s (%s)', __('Töleg möçberi'), __('TMT')), 'payment_amount')
|
||||||
->fullWidth()
|
->fullWidth()
|
||||||
->required()
|
->required()
|
||||||
->rules('required', 'rules:250'),
|
->rules('required', 'max:' . $max_value)
|
||||||
|
->help("Iň ýokary möçberi: {$max_value} TMT"),
|
||||||
|
|
||||||
|
Text::make(__('USD ekwalendi'), 'usd_rate')
|
||||||
|
->fullWidth()
|
||||||
|
->readonly()
|
||||||
|
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) {
|
||||||
|
if ($formData->payment_amount) {
|
||||||
|
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt->value, 2));
|
||||||
|
} else {
|
||||||
|
$field->setValue('');
|
||||||
|
}
|
||||||
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class CurrencyRate extends Resource
|
|||||||
|
|
||||||
Text::make('Value', 'value')
|
Text::make('Value', 'value')
|
||||||
->fullWidth()
|
->fullWidth()
|
||||||
|
->help('Bitin däl sanlary "." bilen ýazmaly')
|
||||||
->rules('required', 'numeric'),
|
->rules('required', 'numeric'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?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::table('currency_rates', function (Blueprint $table) {
|
||||||
|
$table->index(['currency_from', 'currency_to']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('currency_rates', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('currency_rates_currency_from_currency_to_index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user