phpstan 5 errors fixed
This commit is contained in:
@@ -43,7 +43,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
{
|
||||
if (is_null($fields->payment_amount) || is_null($fields->usd_payment)) {
|
||||
if (! property_exists($fields, 'payment_amount') || ! property_exists($fields, 'usd_payment')) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'Töleg maglumatlary ýok!',
|
||||
'body' => 'Töleg maglumatlary girizilmedik',
|
||||
@@ -108,7 +108,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
|
||||
$usd_to_tmt = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value')?->value);
|
||||
|
||||
$payment_warning_text = VisaMasterSettings::where('name', 'payment_warning_text')->first();
|
||||
|
||||
@@ -116,11 +116,11 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
return [];
|
||||
}
|
||||
|
||||
$max_value = number_format($usd_to_tmt->value * 250, 2);
|
||||
$max_value = number_format($usd_to_tmt * 250, 2);
|
||||
|
||||
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">Bankyň tutumy: 20 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 3 TMT</h3>
|
||||
HTML))->asHtml(),
|
||||
@@ -140,8 +140,8 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
->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, '.', ''));
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt, 2, '.', ''));
|
||||
} else {
|
||||
$field->setValue('');
|
||||
}
|
||||
@@ -149,8 +149,8 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
|
||||
Hidden::make('usd_payment')
|
||||
->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, '.', ''));
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt, 2, '.', ''));
|
||||
} else {
|
||||
$field->setValue('');
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) {
|
||||
if (is_numeric($formData->payment_amount)) {
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(
|
||||
floatval(number_format($formData->payment_amount, 2, '.', '')) + 23
|
||||
);
|
||||
@@ -265,6 +265,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
// Condition 1: Check if today is the last day of the month
|
||||
if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) {
|
||||
info('check 1');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -276,6 +277,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
$forbiddenDays = ['Friday', 'Saturday', 'Sunday'];
|
||||
if (in_array($today->format('l'), $forbiddenDays)) {
|
||||
info('check 2');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -283,6 +285,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
// Condition 3: If the last day is Saturday, disallow Friday
|
||||
if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') {
|
||||
info('check 3');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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, '.', '')
|
||||
);
|
||||
|
||||
10
app/Nova/Actions/Sber/SberActionFields.php
Normal file
10
app/Nova/Actions/Sber/SberActionFields.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Actions\Sber;
|
||||
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
|
||||
/**
|
||||
* @property string $payment_amount
|
||||
*/
|
||||
class SberActionFields extends ActionFields {}
|
||||
@@ -40,10 +40,6 @@ trait CurrencyRateAuth
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException;
|
||||
}
|
||||
|
||||
@@ -74,6 +70,6 @@ trait CurrencyRateAuth
|
||||
/** Force delete */
|
||||
public function authorizedToForceDelete(Request $request)
|
||||
{
|
||||
throw_unless(auth()->user()->isMe(), AuthorizationException::class);
|
||||
return auth()->user()->isMe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class NovaVisaMasterSetting extends Resource
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var class-string<\App\Models\Resources\NovaVisaMasterSetting>
|
||||
* @var class-string<\App\Modules\VisaMasterSettings\Models\VisaMasterSettings>
|
||||
*/
|
||||
public static $model = \App\Modules\VisaMasterSettings\Models\VisaMasterSettings::class;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\System\Roles\Permission;
|
||||
use App\Nova\Resources\System\Roles\Role;
|
||||
@@ -107,8 +108,9 @@ class User extends Resource
|
||||
|
||||
Boolean::make(__('Phone verified'), 'phone_verified_at')
|
||||
->default(false)
|
||||
->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
|
||||
->fillUsing(function (NovaRequest $request, $model, string $attribute, string $requestAttribute) {
|
||||
if ($request->boolean('phone_verified_at')) {
|
||||
/** @var UserModel $model */
|
||||
$model->phone_verified_at = now();
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user