diff --git a/app/Models/CurrencyRate.php b/app/Models/CurrencyRate.php index e59b372..4bf0775 100644 --- a/app/Models/CurrencyRate.php +++ b/app/Models/CurrencyRate.php @@ -5,6 +5,14 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +/** + * @property int $id + * @property string $currency_from + * @property string $currency_to + * @property string $value + * @property \Illuminate\Support\Carbon $created_at + * @property \Illuminate\Support\Carbon $updated_at + */ class CurrencyRate extends Model { use HasFactory; diff --git a/app/Models/Order/Loan/LoanOrder.php b/app/Models/Order/Loan/LoanOrder.php index 8510704..9b5d874 100644 --- a/app/Models/Order/Loan/LoanOrder.php +++ b/app/Models/Order/Loan/LoanOrder.php @@ -12,6 +12,78 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Laravel\Nova\Actions\Actionable; +/** + * @property int $id + * @property string $unique_id + * @property int $loan_type + * @property string $region + * @property int $branch_id + * @property string $customer_name + * @property string $customer_surname + * @property string $customer_patronic_name + * @property string $passport_address + * @property string $real_address + * @property string $passport_serie + * @property string $passport_id + * @property string $passport_given_at + * @property string $passport_given_by + * @property string $born_place + * @property string $born_at + * @property string $email + * @property string $phone + * @property string $phone_additional + * @property string $phone_home + * @property string $work_region + * @property int $work_province_id + * @property string $work_company + * @property string $work_company_accountant_number + * @property string $work_started_at + * @property string $work_salary + * @property string $work_position + * @property string $education + * @property string $marriage_status + * @property string $passport_one + * @property string $passport_two + * @property string $passport_three + * @property string $passport_four + * @property string $user_id + * @property string $status + * @property string $notes + * @property string $created_at + * @property string $updated_at + * @property string $deleted_at + * @property string $loan_amount + * @property string $card_number + * @property string $card_name + * @property string $card_month + * @property string $card_year + * @property string $guarantor_name + * @property string $guarantor_surname + * @property string $guarantor_patronic_name + * @property string $guarantor_card_number + * @property string $guarantor_card_name + * @property string $guarantor_card_month + * @property string $guarantor_card_year + * @property string $guarantor_2_name + * @property string $guarantor_2_surname + * @property string $guarantor_2_patronic_name + * @property string $guarantor_2_card_number + * @property string $guarantor_2_card_name + * @property string $guarantor_2_card_month + * @property string $guarantor_2_card_year + * @property string $source + * @property string $guarantor_note + * @property string $guarantor_2_note + * @property string $satisfiable + * @property string $guarantor_passport_serie + * @property string $guarantor_passport_id + * @property string $guarantor_2_passport_serie + * @property string $guarantor_2_passport_id + * @property string $loan_card_number + * @property string $loan_card_name + * @property string $loan_card_month + * @property string $loan_card_yea + */ class LoanOrder extends Model { use Actionable; diff --git a/app/Models/Payment/OnlinePaymentHistory.php b/app/Models/Payment/OnlinePaymentHistory.php index bcdd222..2405189 100644 --- a/app/Models/Payment/OnlinePaymentHistory.php +++ b/app/Models/Payment/OnlinePaymentHistory.php @@ -15,11 +15,4 @@ class OnlinePaymentHistory extends Model * @var string */ protected $table = 'online_payment_histories'; - - /** - * Guarded attributes - * - * @var array - */ - protected $guarded = []; } diff --git a/app/Models/User.php b/app/Models/User.php index 48af5d9..6b6e53e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -14,6 +14,21 @@ use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use Spatie\Permission\Traits\HasRoles; +/** + * @property int $id + * @property string $username + * @property string $name + * @property string $email + * @property string $phone + * @property null|\Illuminate\Support\Carbon $email_verified_at + * @property null|\Illuminate\Support\Carbon $phone_verified_at + * @property string $password + * @property string $locale + * @property bool $active + * @property string $remember_token + * @property \Illuminate\Support\Carbon $created_at + * @property \Illuminate\Support\Carbon $updated_at + */ class User extends Authenticatable { use HasApiTokens; @@ -153,7 +168,7 @@ class User extends Authenticatable */ public function ownsLoanOrder(LoanOrder $loanOrder): bool { - return $this->id === $loanOrder->user_id; + return $this->id === intval($loanOrder->user_id); } /** @@ -161,7 +176,7 @@ class User extends Authenticatable */ public function ownsCardOrder(CardOrder $cardOrder): bool { - return $this->id === $cardOrder->user_id; + return $this->id === intval($cardOrder->user_id); } /** diff --git a/app/Modules/LoanOrder/Controllers/LoanOrderController.php b/app/Modules/LoanOrder/Controllers/LoanOrderController.php index c611593..9a25e15 100644 --- a/app/Modules/LoanOrder/Controllers/LoanOrderController.php +++ b/app/Modules/LoanOrder/Controllers/LoanOrderController.php @@ -84,7 +84,7 @@ class LoanOrderController extends Controller public function show(LoanOrder $loanOrder) { if ($loanOrder->user_id === auth()->id()) { - return response()->status(403); + return response(status: 403); } return response()->json(new LoanOrderShowResource($loanOrder)); @@ -104,7 +104,7 @@ class LoanOrderController extends Controller public function destroy(LoanOrder $loanOrder) { if ($loanOrder->user_id === auth()->id()) { - return response()->status(403); + return response(status: 403); } $loanOrder->delete(); diff --git a/app/Modules/LoanOrder/Controllers/Resources/LoanOrderIndexResource.php b/app/Modules/LoanOrder/Controllers/Resources/LoanOrderIndexResource.php index 0c4138d..b48efa2 100644 --- a/app/Modules/LoanOrder/Controllers/Resources/LoanOrderIndexResource.php +++ b/app/Modules/LoanOrder/Controllers/Resources/LoanOrderIndexResource.php @@ -6,6 +6,9 @@ use App\Repos\Order\OrderRepo; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin \App\Models\Order\Loan\LoanOrder + */ class LoanOrderIndexResource extends JsonResource { /** diff --git a/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php b/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php index 253fdf4..e9b60f1 100644 --- a/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php +++ b/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php @@ -10,6 +10,9 @@ use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\Facades\Storage; +/** + * @mixin \App\Models\Order\Loan\LoanOrder + */ class LoanOrderShowResource extends JsonResource { /** diff --git a/app/Modules/SberPaymentOrder/Models/SberPaymentOrder.php b/app/Modules/SberPaymentOrder/Models/SberPaymentOrder.php index 951d703..d927a4c 100644 --- a/app/Modules/SberPaymentOrder/Models/SberPaymentOrder.php +++ b/app/Modules/SberPaymentOrder/Models/SberPaymentOrder.php @@ -10,6 +10,28 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; +/** + * @property int $id + * @property string $unique_id + * @property string $type + * @property string $passport_name + * @property string $passport_surname + * @property string $phone + * @property string $email + * @property string $region + * @property int $branch_id + * @property int $user_id + * @property string $address + * @property array $sender_datas + * @property array $payment_reciever + * @property string $documents + * @property string $status + * @property string $notes + * @property \Illuminate\Support\Carbon $created_at + * @property \Illuminate\Support\Carbon $updated_at + * @property bool $paid + * @property \Illuminate\Support\Carbon $deleted_at + */ class SberPaymentOrder extends Model implements HasMedia { use InteractsWithMedia; diff --git a/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php b/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php index 64c8cf4..77fa43f 100644 --- a/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php +++ b/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php @@ -2,6 +2,7 @@ namespace App\Modules\SberPaymentOrder\Nova\Resources\Concerns; +use App\Modules\SberPaymentOrder\Models\SberPaymentOrder; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Http\Request; @@ -16,7 +17,9 @@ trait NovaSberPaymentOrderAuth return; } - if ($this->resource->user_id == auth()->id()) { + /** @var SberPaymentOrder $resource */ + $resource = $this->resource; + if ($resource->user_id == auth()->id()) { return; } @@ -44,7 +47,9 @@ trait NovaSberPaymentOrderAuth return; } - if ($this->resource->user_id == auth()->id()) { + /** @var SberPaymentOrder $resource */ + $resource = $this->resource; + if ($resource->user_id == auth()->id()) { return; } @@ -78,6 +83,6 @@ trait NovaSberPaymentOrderAuth /** Force delete */ public function authorizedToForceDelete(Request $request) { - throw_unless(auth()->user()->isMe(), AuthorizationException::class); + return auth()->user()->isMe(); } } diff --git a/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php b/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php index cf10d18..bdbeb64 100644 --- a/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php +++ b/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php @@ -332,7 +332,10 @@ class NovaSberPaymentOrder extends Resource ->icon('credit-card') ->sole() ->canSee(function ($request) { - if (in_array($this->resource->status, [ + /** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $resource */ + $resource = $this->resource; + + if (in_array($resource->status, [ OrderRepo::PENDING, OrderRepo::CANCELLED, ])) { diff --git a/app/Modules/TuitionPaymentOrder/Nova/Resources/NovaTuitionPaymentOrder.php b/app/Modules/TuitionPaymentOrder/Nova/Resources/NovaTuitionPaymentOrder.php index 6f5996c..b23ced1 100644 --- a/app/Modules/TuitionPaymentOrder/Nova/Resources/NovaTuitionPaymentOrder.php +++ b/app/Modules/TuitionPaymentOrder/Nova/Resources/NovaTuitionPaymentOrder.php @@ -119,129 +119,129 @@ class NovaTuitionPaymentOrder extends Resource public function fields(NovaRequest $request): array { return [ - Tabs::make('Wizard', [ - new Tab(__('Status'), [ - ID::make() - ->hideFromDetail(), + // Tabs::make('Wizard', [ + // new Tab(__('Status'), [ + // ID::make() + // ->hideFromDetail(), - Hidden::make('user_id') - ->default(auth()->id()) - ->hideWhenUpdating(), + // Hidden::make('user_id') + // ->default(auth()->id()) + // ->hideWhenUpdating(), - Text::make(__('ID'), 'unique_id') - ->exceptOnForms(), + // Text::make(__('ID'), 'unique_id') + // ->exceptOnForms(), - Select::make(__('Status'), 'status') - ->displayUsingLabels() - ->searchable() - ->options(OrderRepo::statusValues()) - ->default(OrderRepo::defaultStatus()) - ->fullWidth() - ->hideFromDetail() - ->rules('required') - ->canSeeWhen('systemUser', $this), + // Select::make(__('Status'), 'status') + // ->displayUsingLabels() + // ->searchable() + // ->options(OrderRepo::statusValues()) + // ->default(OrderRepo::defaultStatus()) + // ->fullWidth() + // ->hideFromDetail() + // ->rules('required') + // ->canSeeWhen('systemUser', $this), - Badge::make(__('Status'), 'status') - ->map(OrderRepo::statusClasses()) - ->addTypes([ - 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', - ]) - ->labels(OrderRepo::statusValues()) - ->withIcons() - ->icons(OrderRepo::statusIcons()), + // Badge::make(__('Status'), 'status') + // ->map(OrderRepo::statusClasses()) + // ->addTypes([ + // 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', + // ]) + // ->labels(OrderRepo::statusValues()) + // ->withIcons() + // ->icons(OrderRepo::statusIcons()), - Text::make(__('Note'), 'notes') - ->fullWidth() - ->canSeeWhen('systemUser', $this), - ]), + // Text::make(__('Note'), 'notes') + // ->fullWidth() + // ->canSeeWhen('systemUser', $this), + // ]), - new Tab(__('Location'), [ - Select::make(__('Region'), 'region') - ->fullWidth() - ->displayUsingLabels() - ->searchable() - ->options(RegionRepo::values()) - ->default(RegionRepo::default()) - ->rules('required') - ->sortable(), + // new Tab(__('Location'), [ + // Select::make(__('Region'), 'region') + // ->fullWidth() + // ->displayUsingLabels() + // ->searchable() + // ->options(RegionRepo::values()) + // ->default(RegionRepo::default()) + // ->rules('required') + // ->sortable(), - Select::make(__('Branch'), 'branch_id') - ->fullWidth() - ->displayUsingLabels() - ->searchable() - ->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class)) - ->rules('required') - ->sortable(), - ]), + // Select::make(__('Branch'), 'branch_id') + // ->fullWidth() + // ->displayUsingLabels() + // ->searchable() + // ->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class)) + // ->rules('required') + // ->sortable(), + // ]), - new Tab(__('Personal data'), [ - Text::make(__('Passport name'), 'passport_name') - ->fullWidth() - ->rules('required', 'string', 'max:255'), + // new Tab(__('Personal data'), [ + // Text::make(__('Passport name'), 'passport_name') + // ->fullWidth() + // ->rules('required', 'string', 'max:255'), - Text::make(__('Passport surname'), 'passport_surname') - ->fullWidth() - ->rules('required', 'string', 'max:255'), + // Text::make(__('Passport surname'), 'passport_surname') + // ->fullWidth() + // ->rules('required', 'string', 'max:255'), - NovaInputmask::make(__('Phone'), 'phone') - ->fullWidth() - ->phonenumber('TM') - ->rules('required', 'max:255') - ->hideFromIndex(), + // NovaInputmask::make(__('Phone'), 'phone') + // ->fullWidth() + // ->phonenumber('TM') + // ->rules('required', 'max:255') + // ->hideFromIndex(), - Text::make(__('Email'), 'email') - ->fullWidth() - ->rules('nullable', 'max:255', 'email') - ->hideFromIndex(), + // Text::make(__('Email'), 'email') + // ->fullWidth() + // ->rules('nullable', 'max:255', 'email') + // ->hideFromIndex(), - Text::make(__('Current Residence'), 'address') - ->fullWidth() - ->rules('required', 'string', 'max:255') - ->hideFromIndex(), - ]), + // Text::make(__('Current Residence'), 'address') + // ->fullWidth() + // ->rules('required', 'string', 'max:255') + // ->hideFromIndex(), + // ]), - new Tab(__('Payment'), [ - SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [ - Select::make(__('Passport serie'), 'passport_serie') - ->displayUsingLabels() - ->searchable() - ->options(PassportRepo::values()) - ->rules('required') - ->sortable(), + // new Tab(__('Payment'), [ + // SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [ + // Select::make(__('Passport serie'), 'passport_serie') + // ->displayUsingLabels() + // ->searchable() + // ->options(PassportRepo::values()) + // ->rules('required') + // ->sortable(), - NovaInputmask::make(__('Passport number'), 'passport_number') - ->mask('999999') - ->rules('required', 'max:255'), + // NovaInputmask::make(__('Passport number'), 'passport_number') + // ->mask('999999') + // ->rules('required', 'max:255'), - Text::make( - name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')), - attribute: 'full_name' - ) - ->rules('required', 'max:255'), - ])->minRows(1)->rules('required'), + // Text::make( + // name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')), + // attribute: 'full_name' + // ) + // ->rules('required', 'max:255'), + // ])->minRows(1)->rules('required'), - SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [ - Select::make(__('Passport serie'), 'passport_serie') - ->displayUsingLabels() - ->searchable() - ->options(PassportRepo::values()) - ->rules('required') - ->sortable(), + // SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [ + // Select::make(__('Passport serie'), 'passport_serie') + // ->displayUsingLabels() + // ->searchable() + // ->options(PassportRepo::values()) + // ->rules('required') + // ->sortable(), - NovaInputmask::make(__('Passport number'), 'passport_number') - ->mask('999999') - ->rules('required', 'max:255'), + // NovaInputmask::make(__('Passport number'), 'passport_number') + // ->mask('999999') + // ->rules('required', 'max:255'), - Text::make( - name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')), - attribute: 'full_name' - )->rules('required', 'max:255'), - ])->maxRows(1)->minRows(1)->rules('required'), - ]), + // Text::make( + // name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')), + // attribute: 'full_name' + // )->rules('required', 'max:255'), + // ])->maxRows(1)->minRows(1)->rules('required'), + // ]), - new Tab(__('Reciver files'), TuitionPaymentOrderFileFields::reciverFiles()), - new Tab(__('Sender files'), TuitionPaymentOrderFileFields::senderFiles()), - ], $request)->asWizard(), + // new Tab(__('Reciver files'), TuitionPaymentOrderFileFields::reciverFiles()), + // new Tab(__('Sender files'), TuitionPaymentOrderFileFields::senderFiles()), + // ], $request)->asWizard(), ]; } } diff --git a/app/Modules/TuitionPaymentOrder/Nova/Resources/TuitionPaymentOrderFileFields.php b/app/Modules/TuitionPaymentOrder/Nova/Resources/TuitionPaymentOrderFileFields.php index 384967a..e125688 100644 --- a/app/Modules/TuitionPaymentOrder/Nova/Resources/TuitionPaymentOrderFileFields.php +++ b/app/Modules/TuitionPaymentOrder/Nova/Resources/TuitionPaymentOrderFileFields.php @@ -20,17 +20,17 @@ class TuitionPaymentOrderFileFields ->fullWidth() ->deletable(false) ->creationRules($file['required'] ? 'required' : 'nullable') - ->updateRules('nullable') - ->store(function (NovaRequest $request, $model) use ($file) { - return function () use ($model, $file) { - $model->addMediaFromRequest($file['code']) - ->preservingOriginal() - ->toMediaCollection($file['code']); - }; - }) - ->preview(function ($value, $disk, $resource) use ($file) { - return $resource->getFirstMediaUrl($file['code']); - }); + ->updateRules('nullable'); + // ->store(function (NovaRequest $request, $model) use ($file) { + // return function () use ($model, $file) { + // $model->addMediaFromRequest($file['code']) + // ->preservingOriginal() + // ->toMediaCollection($file['code']); + // }; + // }) + // ->preview(function ($value, $disk, $resource) use ($file) { + // return $resource->getFirstMediaUrl($file['code']); + // }); }) ->toArray(); } @@ -46,17 +46,17 @@ class TuitionPaymentOrderFileFields ->fullWidth() ->deletable(false) ->creationRules($file['required'] ? 'required' : 'nullable') - ->updateRules('nullable') - ->store(function (NovaRequest $request, $model) use ($file) { - return function () use ($model, $file) { - $model->addMediaFromRequest($file['code']) - ->preservingOriginal() - ->toMediaCollection($file['code']); - }; - }) - ->preview(function ($value, $disk, $resource) use ($file) { - return $resource->getFirstMediaUrl($file['code']); - }); + ->updateRules('nullable'); + // ->store(function (NovaRequest $request, $model) use ($file) { + // return function () use ($model, $file) { + // $model->addMediaFromRequest($file['code']) + // ->preservingOriginal() + // ->toMediaCollection($file['code']); + // }; + // }) + // ->preview(function ($value, $disk, $resource) use ($file) { + // return $resource->getFirstMediaUrl($file['code']); + // }); }) ->toArray(); } diff --git a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php index 4eee54f..7c1f6ed 100644 --- a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php +++ b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrder.php @@ -14,6 +14,28 @@ use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; +/** + * @property int $id + * @property string $unique_id + * @property string $type + * @property string $passport_name + * @property string $passport_surname + * @property string $phone + * @property string $email + * @property string $region + * @property int $branch_id + * @property int $user_id + * @property string $address + * @property array $sender_datas + * @property array $payment_reciever + * @property string $documents + * @property string $status + * @property string $notes + * @property \Illuminate\Support\Carbon $created_at + * @property \Illuminate\Support\Carbon $updated_at + * @property bool $paid + * @property \Illuminate\Support\Carbon $deleted_at + */ class VisaMasterPaymentOrder extends Model implements HasMedia { use InteractsWithMedia; diff --git a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrderItem.php b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrderItem.php index 65212fa..b087351 100644 --- a/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrderItem.php +++ b/app/Modules/VisaMasterPaymentOrder/Models/VisaMasterPaymentOrderItem.php @@ -7,6 +7,19 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; +/** + * @property int $id + * @property int $visa_master_payment_order_id + * @property int $online_payment_history_id + * @property ?string $payer_name + * @property ?string $payer_card + * @property ?string $payment_order_number + * @property string $tmt_payment_amount + * @property string $usd_payment_amount + * @property bool $paid + * @property \Illuminate\Support\Carbon $created_at + * @property \Illuminate\Support\Carbon $updated_at + */ class VisaMasterPaymentOrderItem extends Model implements HasMedia { use InteractsWithMedia; diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterAuth.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterAuth.php index 79801d6..d0d33e5 100644 --- a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterAuth.php +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterAuth.php @@ -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; } diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php index 060119c..1d4b5f1 100644 --- a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php @@ -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, ])) { diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrderItem.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrderItem.php index a5277cf..649bf9e 100644 --- a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrderItem.php +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrderItem.php @@ -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); diff --git a/app/Modules/VisaMasterSettings/Models/VisaMasterSettings.php b/app/Modules/VisaMasterSettings/Models/VisaMasterSettings.php index 2f65e86..80d7116 100644 --- a/app/Modules/VisaMasterSettings/Models/VisaMasterSettings.php +++ b/app/Modules/VisaMasterSettings/Models/VisaMasterSettings.php @@ -4,6 +4,9 @@ namespace App\Modules\VisaMasterSettings\Models; use Illuminate\Database\Eloquent\Model; +/** + * @property string $value + */ class VisaMasterSettings extends Model { protected $table = 'visa_master_settings'; diff --git a/app/Nova/Actions/MakePaymentNovaVisaMaster.php b/app/Nova/Actions/MakePaymentNovaVisaMaster.php index bb5ebcb..3c691bc 100644 --- a/app/Nova/Actions/MakePaymentNovaVisaMaster.php +++ b/app/Nova/Actions/MakePaymentNovaVisaMaster.php @@ -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(<<1 USD = $usd_to_tmt->value TMT +