phpstan 5 errors fixed

This commit is contained in:
2024-11-25 15:34:09 +05:00
parent 2e0cc45e99
commit 0d875acc4e
28 changed files with 463 additions and 248 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request;
@@ -16,7 +17,10 @@ trait VisaMasterAuth
return;
}
if ($this->resource->user_id == auth()->id()) {
/** @var VisaMasterPaymentOrder $resource */
$resource = $this->resource;
if ($resource->user_id == auth()->id()) {
return;
}
@@ -44,7 +48,10 @@ trait VisaMasterAuth
return;
}
if ($this->resource->user_id == auth()->id()) {
/** @var VisaMasterPaymentOrder $resource */
$resource = $this->resource;
if ($resource->user_id == auth()->id()) {
return;
}

View File

@@ -4,6 +4,7 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources;
use App\Models\Branch\Branch;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder as VisaMasterPaymentOrderModel;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterAuth;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForDetail;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForIndex;
@@ -358,7 +359,10 @@ class NovaVisaMasterPaymentOrder extends Resource
->icon('credit-card')
->sole()
->canSee(function ($request) {
if (in_array($this->resource->status, [
/** @var VisaMasterPaymentOrderModel $order */
$order = $this->resource;
if (in_array($order->status, [
OrderRepo::PENDING,
OrderRepo::CANCELLED,
])) {

View File

@@ -4,11 +4,12 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources;
use App\Models\Branch\Branch;
use App\Models\Payment\OnlinePaymentHistory;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem as VisaMasterPaymentOrderItemModel;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Item\NovaVisaMasterPaymentOrderItemAuth;
use App\Nova\Actions\CheckOnlinePayment;
use App\Nova\Resource;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
@@ -19,7 +20,7 @@ use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
/**
* @template TModel of \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder
* @template TModel of \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem
*/
class NovaVisaMasterPaymentOrderItem extends Resource
{
@@ -28,7 +29,7 @@ class NovaVisaMasterPaymentOrderItem extends Resource
/**
* The model the resource corresponds to.
*
* @var class-string<\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder>
* @var class-string<\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem>
*/
public static $model = \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem::class;
@@ -107,16 +108,16 @@ class NovaVisaMasterPaymentOrderItem extends Resource
Text::make('Amaly geçiren raýatyň kart belgisi (mask)', 'payer_card'),
Text::make('Töleg ýyly', fn () => $this->created_at->format('Y')),
Text::make('Töleg aýy', fn () => $this->created_at->translatedFormat('F')),
Text::make('Töleg ýyly', fn ($model) => $model->format('Y')),
Text::make('Töleg aýy', fn ($model) => $model->created_at->translatedFormat('F')),
Text::make('Amalyň geçirilen wagty', fn () => $this->created_at->format('H:i, d.m.Y')),
Text::make('Amalyň geçirilen wagty', fn ($model) => $model->created_at->format('H:i, d.m.Y')),
Text::make('Amalyň möçberi', fn () => $this->usd_payment_amount.' USD'),
Text::make('Amalyň möçberi', fn ($model) => $model->usd_payment_amount.' USD'),
Text::make('Amalyň manat möçberi', fn () => $this->tmt_payment_amount.' TMT'),
Text::make('Amalyň manat möçberi', fn ($model) => $model->tmt_payment_amount.' TMT'),
Text::make('Amalyň referensi', fn () => $this->payment_order_number),
Text::make('Amalyň referensi', fn ($model) => $model->payment_order_number),
Boolean::make(__('Paid'), 'paid'),
];
@@ -126,7 +127,8 @@ class NovaVisaMasterPaymentOrderItem extends Resource
{
return [
Action::using('HALKBANK töleg barla', function (ActionFields $fields, Collection $models) {
$item = $onlinePaymentResource = $models->first();
/** @var VisaMasterPaymentOrderItemModel $item */
$item = $models->first();
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);