This commit is contained in:
2024-01-28 17:29:39 +05:00
parent 2dc812711e
commit 0a631aec80
18 changed files with 321 additions and 49 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Models\Payment;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ApiKeyHalkbank extends Model
{
use HasFactory;
/**
* Table name
*
* @var string
*/
protected $table = 'api_key_halkbank';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'order_number',
'billing_username',
'billing_password',
];
/**
* Generate unique order number
*/
public static function generateOrderNumber($resource): int
{
$order_number = static::firstOrCreate([
'billing_username' => $resource->billing_username ?? 'asdasd',
'billing_password' => $resource->billing_password ?? 'asdasd',
], ['order_number' => '01122017270']);
$order_number->update([
'order_number' => $order_number->order_number + 1,
]);
return $order_number->order_number;
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace App\Nova\Forms;
use Closure;
use Illuminate\Support\Str;
class NovaForm
{
/**
* Fill resource empty
*/
public static function fillEmpty(): Closure
{
return function ($request, $model, $attribute, $requestAttribute) {
};
}
/**
* Fill attribute
*/
public static function fillAttribute($key, $value): Closure
{
return function ($request, $model, $attribute, $requestAttribute) use ($key, $value) {
$model->{$key} = $request->input($value);
};
}
/**
* Fill schemaless
*/
public static function fillSchemalessField($schemalessAttribute = 'options'): Closure
{
return function ($request, $model, $attribute, $requestAttribute) use ($schemalessAttribute) {
$model->{$schemalessAttribute}->set($attribute, $request->input($attribute));
};
}
/**
* Save by capitalizing firrt letter
*/
public static function capitalize(): Closure
{
return function ($request, $model, $attribute, $requestAttribute) {
$model->{$attribute} = ucfirst($request->input($attribute));
};
}
/**
* Fill the slug field
*/
public static function fillSlug(string|array $from, ?string $resource): Closure
{
return function ($request, $model, $attribute, $requestAttribute) use ($from, $resource) {
$slugSource = is_array($from) ? data_get($request, implode('.', $from)) : data_get($request, $from);
$slug = Str::slug($slugSource);
$query = $resource ? $resource::where('slug', $slug) : $model::where('slug', $slug);
if ($query->exists()) {
$slug .= Str::random(6);
}
$model->{$attribute} = $slug;
};
}
/**
* Fill media file name
*/
public static function fillMediaFileName(): Closure
{
return fn ($originalFilename, $extension, $model) => sprintf('%s.%s', md5($originalFilename), $extension);
}
}

View File

@@ -6,12 +6,14 @@ use App\Models\Branch\Branch;
use App\Models\Order\Card\CardOrder as CardOrderModel;
use App\Nova\Filters\RegionFilter;
use App\Nova\Filters\StatusFilter;
use App\Nova\Forms\NovaForm;
use App\Nova\Resource;
use App\Nova\Resources\Order\Card\Concerns\CardOrderFieldsForDetail;
use App\Nova\Resources\Order\Card\Concerns\CardOrderFieldsForIndex;
use App\Repos\Order\Card\CardStateRepo;
use App\Repos\Order\Card\CardTypeRepo;
use App\Repos\Order\OrderRepo;
use App\Repos\Payment\OnlinePaymentRepo;
use App\Repos\System\Location\CountryRepo;
use App\Repos\System\Nova\NovaRepo;
use App\Repos\System\Settings\Legal\PassportRepo;
@@ -20,7 +22,6 @@ use App\Rules\DowranAgaAllowed;
use App\Rules\OnlyLetters;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\Hidden;
use Laravel\Nova\Fields\ID;
@@ -30,6 +31,7 @@ use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Panel;
use Laravel\Nova\URL;
use Nurmuhammet\NovaCustomHtml\NovaCustomHtml;
use Nurmuhammet\NovaInputmask\NovaInputmask;
@@ -123,6 +125,30 @@ class CardOrder extends Resource
return $query->where('user_id', $request->user()->id);
}
/**
* Return the location to redirect the user after creation.
*
* @param \Laravel\Nova\Resource $resource
*/
public static function redirectAfterCreate(NovaRequest $request, $resource): URL|string
{
return URL::remote((new OnlinePaymentRepo())->payCardOrder($resource));
}
/**
* Return the location to redirect the user after update.
*
* @param \Laravel\Nova\Resource $resource
* @return \Laravel\Nova\URL|string
*/
public static function redirectAfterUpdate(NovaRequest $request, $resource)
{
return URL::remote(
(new OnlinePaymentRepo())
->payCardOrder($resource),
);
}
/**
* Get the fields for index.
*/
@@ -306,11 +332,11 @@ class CardOrder extends Resource
->rules('max:2048', 'mimes:jpg,png,jpeg')
->creationRules('required')
->updateRules('nullable'),
NovaCustomHtml::make(__('Data'), 'ada')
->html(view('orders.cards.contract-agreement')->render()),
]),
NovaCustomHtml::make(__('Data'), 'ada')
->html(view('orders.cards.contract-agreement')->render())
->fillUsing(NovaForm::fillEmpty()),
]),
];
}

View File

@@ -152,18 +152,65 @@ class LoanOrder extends Resource
->default(auth()->id())
->hideWhenUpdating(),
Select::make(__('Status'), 'status')
->displayUsingLabels()
->searchable()
->options(OrderRepo::statusValues())
->default(OrderRepo::defaultStatus())
->fullWidth()
->rules('required')
->canSeeWhen('systemUser', $this),
new Panel(__('New :resource', ['resource' => $this->singularLabel()]), [
Select::make(__('Status'), 'status')
->displayUsingLabels()
->searchable()
->options(OrderRepo::statusValues())
->default(OrderRepo::defaultStatus())
->fullWidth()
->rules('required')
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
Text::make(__('Note'), 'notes')
->fullWidth()
->canSeeWhen('systemUser', $this),
]),
new Panel(__('Loan'), [
Select::make(__('Loan type'), 'loan_type')

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Repos\Payment;
use App\Models\Payment\ApiKeyHalkbank;
use Illuminate\Support\Facades\Http;
class OnlinePaymentRepo
{
public function payCardOrder($resource): string
{
$orderNumber = $this->generateOrderNumber($resource);
$response = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
'orderNumber' => $orderNumber,
'amount' => $booking->total_price.'00',
'currency' => 934,
'language' => 'ru',
'userName' => 301161000067,
'password' => 'E3vb2SR3dgTPdff',
'returnUrl' => route('online-payment-store'),
'failUrl' => route('online-payment-store'),
'pageView' => 'DESKTOP',
'description' => 'Sargyt',
]);
return 'a';
}
/**
* Generate order number for payment
*/
public function generateOrderNumber($resource): int
{
return ApiKeyHalkbank::generateOrderNumber($resource);
}
}

View File

@@ -19,7 +19,7 @@
"morrislaptop/laravel-pulse-4xx": "^0.0.2",
"nurmuhammet/nova-custom-html": "^1.0",
"nurmuhammet/nova-inputmask": "^1.0",
"outl1ne/nova-grid": "dev-revert-back",
"outl1ne/nova-grid": "@dev",
"outl1ne/nova-translatable": "^2.2",
"spatie/laravel-backup": "^8.4",
"spatie/laravel-permission": "^6.1",
@@ -82,10 +82,6 @@
"0": {
"type": "vcs",
"url": "https://github.com/anditsung/nova-locale-switcher"
},
"1": {
"type": "vcs",
"url": "https://github.com/nurmuhammet-ali/nova-grid"
}
},
"config": {

24
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "72940f1cdfb2570167bdb444d8b28b15",
"content-hash": "e85848a2ef7c35d8eff644ed1eb79219",
"packages": [
{
"name": "brick/math",
@@ -2016,11 +2016,11 @@
},
{
"name": "laravel/nova",
"version": "4.29.0",
"version": "4.31.3",
"dist": {
"type": "path",
"url": "./nova",
"reference": "817463fa9a1fa193367169366f2049bdb1cfca6d"
"reference": "f4a55115ca40a73cb567fbc390beba7f6824f3cf"
},
"require": {
"brick/money": "^0.5.0|^0.6.0|^0.7.0|^0.8.0",
@@ -3931,20 +3931,20 @@
},
{
"name": "outl1ne/nova-grid",
"version": "dev-revert-back",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/nurmuhammet-ali/nova-grid.git",
"reference": "15fb8bcaa21dc010afd2625c6b82c59c1c28d929"
"url": "https://github.com/outl1ne/nova-grid.git",
"reference": "22ed55ed9e3294248469378ba94398dcfad531e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nurmuhammet-ali/nova-grid/zipball/15fb8bcaa21dc010afd2625c6b82c59c1c28d929",
"reference": "15fb8bcaa21dc010afd2625c6b82c59c1c28d929",
"url": "https://api.github.com/repos/outl1ne/nova-grid/zipball/22ed55ed9e3294248469378ba94398dcfad531e9",
"reference": "22ed55ed9e3294248469378ba94398dcfad531e9",
"shasum": ""
},
"require": {
"laravel/nova": "^4.26.5",
"laravel/nova": "^4.29.8",
"php": ">=8.0"
},
"type": "library",
@@ -3960,6 +3960,7 @@
"Outl1ne\\NovaGrid\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@@ -3977,9 +3978,10 @@
"nova"
],
"support": {
"source": "https://github.com/nurmuhammet-ali/nova-grid/tree/main"
"issues": "https://github.com/outl1ne/nova-grid/issues",
"source": "https://github.com/outl1ne/nova-grid/tree/1.0.0"
},
"time": "2024-01-26T18:52:24+00:00"
"time": "2024-01-05T13:46:10+00:00"
},
{
"name": "outl1ne/nova-translatable",

View File

@@ -225,12 +225,12 @@ return [
],
\Morrislaptop\LaravelPulse4xx\FourXxRecorder::class => [
'enabled' => env('PULSE_4XX_ENABLED', true),
'sample_rate' => env('PULSE_4XX_SAMPLE_RATE', 1),
'ignore' => [],
],
'enabled' => env('PULSE_4XX_ENABLED', true),
'sample_rate' => env('PULSE_4XX_SAMPLE_RATE', 1),
'ignore' => [],
],
\Maantje\Pulse\Database\Recorders\DatabaseRecorder::class => [
\Maantje\Pulse\Database\Recorders\DatabaseRecorder::class => [
'connections' => [
'pgsql' => [
'values' => [
@@ -240,7 +240,7 @@ return [
'Innodb_buffer_pool_reads',
'Innodb_buffer_pool_read_requests',
'Innodb_buffer_pool_pages_total',
'Max_used_connections'
'Max_used_connections',
],
'aggregates' => [
'avg' => [
@@ -257,8 +257,8 @@ return [
//
],
],
]
]
],
],
],
],
];

View File

@@ -0,0 +1,30 @@
<?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::create('api_key_halkbank', function (Blueprint $table) {
$table->id();
$table->string('order_number');
$table->string('billing_username');
$table->string('billing_password');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('api_key_for_halkbank');
}
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,8 @@
{
"/app.js": "/app.js?id=a04fdf69751618e7e7574745c73d9f47",
"/app.js": "/app.js?id=8002e7ac36ff237304e3658e951e87a9",
"/manifest.js": "/manifest.js?id=d75058ce2144a4049857d3ff9e02de1e",
"/app.css": "/app.css?id=2b46e7dc4f4700aa130e9b514c5c9a6c",
"/vendor.js": "/vendor.js?id=149e2127cae34c2de25438df9c51f7ba",
"/app.css": "/app.css?id=ef6dd2bb807b5502a73552880aa17c5d",
"/vendor.js": "/vendor.js?id=36b480db2b46429d76e0b35f633618e9",
"/fonts/snunitosansv11pe01mimslybiv1o4x1m8cce4g1pty10iurt9w6fk2a.woff2": "/fonts/snunitosansv11pe01mimslybiv1o4x1m8cce4g1pty10iurt9w6fk2a.woff2?id=c8390e146be0a3c8a5498355dec892ae",
"/fonts/snunitosansv11pe01mimslybiv1o4x1m8cce4g1pty14iurt9w6fk2a.woff2": "/fonts/snunitosansv11pe01mimslybiv1o4x1m8cce4g1pty14iurt9w6fk2a.woff2?id=b0735c7dd6126471acbaf9d6e9f5e41a",
"/fonts/snunitosansv11pe01mimslybiv1o4x1m8cce4g1pty1ciurt9w6fk2a.woff2": "/fonts/snunitosansv11pe01mimslybiv1o4x1m8cce4g1pty1ciurt9w6fk2a.woff2?id=7c1fb232e3050e36dcc1aee61f1d0c06",

File diff suppressed because one or more lines are too long

View File

@@ -466,6 +466,13 @@
* Released under the MIT license
*/
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
/*!
* vuex v4.1.0
* (c) 2022 Evan You
@@ -488,6 +495,8 @@
* Copyright (c) 2016 Jorik Tangelder;
* Licensed under the MIT license */
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.

File diff suppressed because one or more lines are too long

View File

@@ -18,3 +18,7 @@ dialog {
dialog a {
outline: none;
}
/*div[data-popper-placement=bottom-start] {*/
/* display: contents;*/
/*}*/