phpstan 5 errors fixed
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Nova\Actions;
|
||||
use App\Models\CurrencyRate;
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrder;
|
||||
use App\Nova\Actions\Sber\SberActionFields;
|
||||
use App\Repos\Payment\OnlinePaymentRepo;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
@@ -14,7 +15,6 @@ use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Fields\Heading;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
@@ -25,16 +25,13 @@ class MakeSberPaymentAction extends Action
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
public function handle(SberActionFields $fields, Collection $models): mixed
|
||||
{
|
||||
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
|
||||
$payment_amount = floatval($fields->payment_amount);
|
||||
|
||||
if (! $usd_to_tmt) {
|
||||
if (! $usd_to_tmt || ! $payment_amount) {
|
||||
return ActionResponse::danger('Walýuta hasaby girizilmedik, operator bilen habarlaşmagyňyzy haýyş edýärin.');
|
||||
}
|
||||
|
||||
@@ -44,9 +41,9 @@ class MakeSberPaymentAction extends Action
|
||||
return ActionResponse::danger('Şahamça sber tölegi kabul edip bilmeýär.');
|
||||
}
|
||||
|
||||
$tvebTaxTMT = $usd_to_tmt->value * 18;
|
||||
$tvebTaxTMT = floatval($usd_to_tmt->value) * 18;
|
||||
$bankTax = 120.75;
|
||||
$total_amount = number_format($fields->payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '');
|
||||
$total_amount = number_format($payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '');
|
||||
|
||||
$payment = $this->order($resource, $total_amount);
|
||||
|
||||
@@ -63,21 +60,21 @@ class MakeSberPaymentAction extends Action
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
|
||||
$usd_to_rub = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'RUB')->first('value')?->value;
|
||||
$rub_to_tmt = CurrencyRate::where('currency_from', 'RUB')->where('currency_to', 'TMT')->first('value')?->value;
|
||||
$usd_to_tmt = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value')?->value);
|
||||
$usd_to_rub = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'RUB')->first('value')?->value);
|
||||
$rub_to_tmt = floatval(CurrencyRate::where('currency_from', 'RUB')->where('currency_to', 'TMT')->first('value')?->value);
|
||||
|
||||
if (! $usd_to_tmt || ! $usd_to_rub || ! $rub_to_tmt) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$max_value = number_format($usd_to_rub * 250 * $rub_to_tmt, 2, '.', '');
|
||||
$tvebTaxTMT = $usd_to_tmt->value * 18;
|
||||
$tvebTaxTMT = $usd_to_tmt * 18;
|
||||
$bankTax = 120.75;
|
||||
|
||||
return [
|
||||
Heading::make(Blade::render(<<<HTML
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt->value TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 RUB = $rub_to_tmt TMT</h3>
|
||||
<br>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">TVEB USD tutumy: 18 USD</h3>
|
||||
@@ -96,7 +93,7 @@ class MakeSberPaymentAction extends Action
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_rub, $rub_to_tmt) {
|
||||
if ($formData->payment_amount) {
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$usdValue = number_format($formData->payment_amount / ($usd_to_rub * $rub_to_tmt), 2, '.', '');
|
||||
|
||||
$field->setValue($usdValue);
|
||||
@@ -109,7 +106,7 @@ class MakeSberPaymentAction extends Action
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) use ($tvebTaxTMT, $bankTax) {
|
||||
if (is_numeric($formData->payment_amount)) {
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(
|
||||
number_format($formData->payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user