wip
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite;
|
||||
|
||||
use App\Http\Controllers\Api\CardRequisite\Requests\CardRequisiteStoreRequest;
|
||||
use App\Http\Controllers\Api\CardRequisite\Requests\CardRequisiteUpdateRequest;
|
||||
use App\Http\Controllers\Api\CardRequisite\Resources\CardRequisiteIndexResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\Requisite\CardRequisite;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Actions\DownloadCardRequisite;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart rekwizitler')]
|
||||
class CardRequisiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(CardRequisiteIndexResource::collection(
|
||||
CardRequisite::query()
|
||||
->with(['cardType', 'branch'])
|
||||
->where('user_id', auth()->id())
|
||||
->get()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(CardRequisiteStoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
$model = CardRequisite::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
'status' => OrderRepo::PENDING,
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
|
||||
$model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload files
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach (['passport_one', 'passport_two', 'passport_three', 'passport_four'] as $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$files[$field] = Str::after($request->file($field)->store('public'), 'public/');
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da. Soň page-da download button bolmaly, basaňdan soň, `/api/card-requisites-download/{order}` route gelyan file download etmeli.
|
||||
*/
|
||||
public function show(CardRequisite $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new CardRequisiteIndexResource($order));
|
||||
}
|
||||
|
||||
/**
|
||||
* Download*
|
||||
*
|
||||
* Download card transaction file
|
||||
*/
|
||||
public function download(Request $request, CardRequisite $order)
|
||||
{
|
||||
$date = today()->format('d.m.Y');
|
||||
|
||||
$response = vp_fetch_ClientInfoAll($order, $date, $date);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'url' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
$path = DownloadCardRequisite::make()->generateFile($order, $response);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => $response->message,
|
||||
'url' => url($path),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(CardRequisiteUpdateRequest $request, CardRequisite $order): JsonResponse
|
||||
{
|
||||
$data = array_merge($request->validated(), $this->uploadedFiles($request));
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(CardRequisite $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite\Requests;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardRequisiteStoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['required', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['required', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['required', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['required', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['required', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['required', 'integer', 'between:61000000, 71999999'],
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite\Requests;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardRequisiteUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['sometimes', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['sometimes', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite\Resources;
|
||||
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Order\Card\Requisite\CardRequisite
|
||||
*/
|
||||
class CardRequisiteIndexResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'unique_id' => $this->unique_id,
|
||||
|
||||
'card_type_id' => $this->cardType?->name,
|
||||
'card_number' => $this->card_number,
|
||||
'card_month' => $this->card_month,
|
||||
'card_year' => $this->card_year,
|
||||
|
||||
'region' => RegionRepo::label($this->region),
|
||||
'branch_id' => $this->branch?->name,
|
||||
|
||||
'customer_name' => $this->customer_name,
|
||||
'customer_surname' => $this->customer_surname,
|
||||
'customer_patronic_name' => $this->customer_patronic_name,
|
||||
|
||||
'born_at' => $this->born_at,
|
||||
'phone' => $this->phone,
|
||||
|
||||
'passport_serie' => $this->passport_serie,
|
||||
'passport_id' => $this->passport_id,
|
||||
|
||||
'passport_one' => url('/storage/'.$this->passport_one),
|
||||
'passport_two' => url('/storage/'.$this->passport_two),
|
||||
'passport_three' => url('/storage/'.$this->passport_three),
|
||||
'passport_four' => url('/storage/'.$this->passport_four),
|
||||
|
||||
'notes' => $this->notes,
|
||||
'user_id' => $this->user_id,
|
||||
|
||||
'status' => OrderRepo::statusFormatted($this->status),
|
||||
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ class CardTransactionsController extends Controller
|
||||
$url = DownloadCardTransaction::make()->doFiles($order, $response);
|
||||
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'status' => true,
|
||||
'message' => $response->message,
|
||||
'url' => $url,
|
||||
]);
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Process\Pipe;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
|
||||
class GitPullController extends Controller
|
||||
{
|
||||
public function index()
|
||||
|
||||
@@ -32,6 +32,8 @@ class AzatApiClientInfoAllResponse
|
||||
|
||||
public string $mfo;
|
||||
|
||||
public string $inn;
|
||||
|
||||
public string $passOrg;
|
||||
|
||||
public string $passDate;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\AlertController;
|
||||
use App\Http\Controllers\Api\CardOrder\CardOrderController;
|
||||
use App\Http\Controllers\Api\CardRequisite\CardRequisiteController;
|
||||
use App\Http\Controllers\Api\CardTransaction\CardTransactionsController;
|
||||
use App\Http\Controllers\Api\FetchLoanHistoryController;
|
||||
use App\Http\Controllers\Api\LoanOrder\Remaining\LoanOrderRemainingOrderController;
|
||||
@@ -43,20 +44,20 @@ Route::middleware(['nova', Authenticate::class, Authorize::class, OnlySystemUser
|
||||
Route::post('fetch-loan-remaining', [FetchLoanRemainingController::class, 'index']);
|
||||
});
|
||||
|
||||
// Auth...
|
||||
// Auth... [tested fully]
|
||||
Route::post('auth/register', [ApiAuthController::class, 'register']);
|
||||
Route::post('auth/login', [ApiAuthController::class, 'login']);
|
||||
Route::post('auth/verify', [ApiAuthController::class, 'verify']);
|
||||
Route::middleware('auth:sanctum')
|
||||
->post('auth/delete-user', [ApiAuthController::class, 'delete']);
|
||||
|
||||
// Branches...
|
||||
// Branches... [tested]
|
||||
Route::get('branches', [BranchController::class, 'index']);
|
||||
|
||||
// Provinces...
|
||||
// Provinces... [tested]
|
||||
Route::get('provinces', [ProvinceController::class, 'index']);
|
||||
|
||||
// Base enums...
|
||||
// Base enums... [tested]
|
||||
Route::get('base-app-enums', [BaseAppEnumController::class, 'index']);
|
||||
|
||||
Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
||||
@@ -64,7 +65,7 @@ Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
||||
Route::get('profile', [ProfileController::class, 'index']);
|
||||
Route::post('profile', [ProfileController::class, 'store']);
|
||||
|
||||
// Metrics... [tested fully]
|
||||
// Metrics... [tested]
|
||||
Route::get('/metrics', [MetricsController::class, 'index']);
|
||||
|
||||
// Loan order... [tested expect: update]
|
||||
@@ -106,4 +107,12 @@ Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
||||
Route::post('card-transactions', [CardTransactionsController::class, 'store']);
|
||||
Route::post('card-transactions/{order}', [CardTransactionsController::class, 'update']);
|
||||
Route::delete('card-transactions/{order}', [CardTransactionsController::class, 'destroy']);
|
||||
|
||||
// Card requisites... [tested fully]
|
||||
Route::get('card-requisites', [CardRequisiteController::class, 'index']);
|
||||
Route::get('card-requisites/{order}', [CardRequisiteController::class, 'show']);
|
||||
Route::get('card-requisites-download/{order}', [CardRequisiteController::class, 'download']);
|
||||
Route::post('card-requisites', [CardRequisiteController::class, 'store']);
|
||||
Route::post('card-requisites/{order}', [CardRequisiteController::class, 'update']);
|
||||
Route::delete('card-requisites/{order}', [CardRequisiteController::class, 'destroy']);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\ApiTesterController;
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Controllers\Auth\RegisterController;
|
||||
use App\Http\Controllers\Auth\ResetPasswordController;
|
||||
use App\Http\Controllers\GitPullController;
|
||||
use App\Http\Controllers\LocaleController;
|
||||
use App\Http\Controllers\OnlinePaymentController;
|
||||
use App\Http\Controllers\PasswordChangeController;
|
||||
@@ -33,10 +31,6 @@ Route::middleware(['auth'])->group(function () {
|
||||
Route::post('password-change', [PasswordChangeController::class, 'update'])->name('password-change.update');
|
||||
});
|
||||
|
||||
Route::get('tester', [ApiTesterController::class, 'index']);
|
||||
|
||||
Route::get('mahmyt', [GitPullController::class, 'index']);
|
||||
|
||||
Route::get('online-payment-store', [OnlinePaymentController::class, 'store'])
|
||||
->name('online-payment-store');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user