wip
This commit is contained in:
@@ -14,6 +14,8 @@ class BaseAppEnumController extends Controller
|
||||
/**
|
||||
* Base app enums
|
||||
*
|
||||
* `System` -daky esasy bolup biljek `Maglumatlar`, köplenç `Select` -larda ulanylýar.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function index(): array
|
||||
|
||||
@@ -11,6 +11,8 @@ class BranchController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST branches
|
||||
*
|
||||
* Bank şahamçalary. http://online.tbbank.gov.tm/work-place/resources/branches
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
@@ -34,7 +34,9 @@ class RetryNovaCardOrderPayment extends Action
|
||||
*/
|
||||
public function authorizedToRun(Request $request, $model)
|
||||
{
|
||||
$this->authorizedToRunAction = ! $model->paid && $model->status === OrderRepo::PENDING;
|
||||
/** @var \App\Models\Order\Card\CardOrder */
|
||||
$cardOrder = $model;
|
||||
$this->authorizedToRunAction = ! $cardOrder->paid && $cardOrder->status === OrderRepo::PENDING;
|
||||
|
||||
return $this->authorizedToRunAction;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ class DateHelperRepository
|
||||
return $month;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static numbers for months
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function staticNumberMonths(): array
|
||||
{
|
||||
return [
|
||||
@@ -58,6 +63,11 @@ class DateHelperRepository
|
||||
return $years;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static numbers for years
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function staticNumberYears(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -9,15 +9,20 @@ use App\Modules\LoanOrder\Controllers\Requests\LoanOrderStoreRequest;
|
||||
use App\Modules\LoanOrder\Controllers\Resources\LoanOrderIndexResource;
|
||||
use App\Modules\LoanOrder\Controllers\Resources\LoanOrderShowResource;
|
||||
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\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Karz - Karz sargytlary Mobile')]
|
||||
class LoanOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST* Loan orders.
|
||||
*
|
||||
* `Karz sargytlary list`-leri list gornushde gelyar. https://online.tbbank.gov.tm/work-place/resources/loan-order-mobiles dan `Label` gorup bilyan. `BaseAppEnum` dan gerek yerlerini match edishene gora alyan.
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
@@ -31,38 +36,51 @@ class LoanOrderController extends Controller
|
||||
|
||||
/**
|
||||
* SAVE* Loan order.
|
||||
*
|
||||
* `Karz sargytlary save`. Example bar, online panelkadan gorup hem bilersin. Update store daky yaly, yone oz ugratyan zadyn update bolyar, eger ugratmasaň, üýtgemez.
|
||||
*/
|
||||
public function store(LoanOrderStoreRequest $request): JsonResponse
|
||||
public function store(LoanOrderStoreRequest $request, LoanOrder $loanOrder): JsonResponse
|
||||
{
|
||||
Log::channel('form_logs')->info('loan-order-store-request', $request->all());
|
||||
Log::channel('form_logs')->info('loan-order-update-request', $request->all());
|
||||
|
||||
$data = $request->validated();
|
||||
|
||||
$months = DateHelperRepository::monthsAsNumber();
|
||||
$years = DateHelperRepository::yearsUntil();
|
||||
|
||||
$data['card_month'] = indexByValue($request->card_month, $months);
|
||||
$data['card_year'] = indexByValue($request->card_year, $years);
|
||||
if ($request->filled('card_month')) {
|
||||
$data['card_month'] = indexByValue($request->card_month, $months);
|
||||
}
|
||||
|
||||
$data['guarantor_card_month'] = indexByValue($request->guarantor_card_month, $months);
|
||||
$data['guarantor_card_year'] = indexByValue($request->guarantor_card_year, $years);
|
||||
if ($request->filled('card_year')) {
|
||||
$data['card_year'] = indexByValue($request->card_year, $years);
|
||||
}
|
||||
|
||||
$data['guarantor_2_card_month'] = indexByValue($request->guarantor_2_card_month, $months);
|
||||
$data['guarantor_2_card_year'] = indexByValue($request->guarantor_2_card_year, $years);
|
||||
if ($request->filled('guarantor_card_month')) {
|
||||
$data['guarantor_card_month'] = indexByValue($request->guarantor_card_month, $months);
|
||||
}
|
||||
|
||||
LoanOrder::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
'status' => OrderRepo::PENDING,
|
||||
'source' => OrderRepo::MOBILE_DEVICE,
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
if ($request->filled('guarantor_card_year')) {
|
||||
$data['guarantor_card_year'] = indexByValue($request->guarantor_card_year, $years);
|
||||
}
|
||||
|
||||
if ($request->filled('guarantor_2_card_month')) {
|
||||
$data['guarantor_2_card_month'] = indexByValue($request->guarantor_2_card_month, $months);
|
||||
}
|
||||
|
||||
if ($request->filled('guarantor_2_card_year')) {
|
||||
$data['guarantor_2_card_year'] = indexByValue($request->guarantor_2_card_year, $years);
|
||||
}
|
||||
|
||||
$data += $this->uploadedFiles($request);
|
||||
|
||||
Model::unguarded(function () use ($loanOrder, $data) {
|
||||
$loanOrder->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
'message' => __('Successfully updates'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,16 +90,21 @@ class LoanOrderController extends Controller
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
return [
|
||||
'passport_one' => Str::after($request->file('passport_one')->store('public'), 'public/'),
|
||||
'passport_two' => Str::after($request->file('passport_two')->store('public'), 'public/'),
|
||||
'passport_three' => Str::after($request->file('passport_three')->store('public'), 'public/'),
|
||||
'passport_four' => Str::after($request->file('passport_four')->store('public'), 'public/'),
|
||||
];
|
||||
$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* Loan order
|
||||
*
|
||||
* `Karz sargytlary show by id`. ID ugradyp alyan route -da. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function show(LoanOrder $loanOrder): JsonResponse
|
||||
{
|
||||
@@ -94,6 +117,8 @@ class LoanOrderController extends Controller
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* `Karz sargytlary update`. ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(Request $request): void
|
||||
{
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanOrder\Controllers\Requests;
|
||||
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LoanOrderUpdateRequest 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 [
|
||||
/**
|
||||
* Loan type id (https://online.tbbank.gov.tm/api/loan-types)
|
||||
*/
|
||||
'loan_type' => ['sometimes', 'integer', Rule::exists('loan_types', 'id')],
|
||||
|
||||
/**
|
||||
* Loan amount
|
||||
*
|
||||
* @example 20000
|
||||
*/
|
||||
'loan_amount' => ['sometimes', 'integer', 'max:40000'],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'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 2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Education (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'education' => ['sometimes', 'string', Rule::in(array_keys(EducationRepo::values()))],
|
||||
|
||||
/**
|
||||
* Marriage status (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'marriage_status' => ['sometimes', 'string', Rule::in(array_keys(MarriageRepo::values()))],
|
||||
|
||||
/**
|
||||
* Passport address
|
||||
*
|
||||
* @example Kemine 100/190
|
||||
*/
|
||||
'passport_address' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Real address
|
||||
*
|
||||
* @example Kemine 100/200
|
||||
*/
|
||||
'real_address' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*/
|
||||
'passport_serie' => ['sometimes', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport date of issue
|
||||
*
|
||||
* @example 2024-01-10
|
||||
*/
|
||||
'passport_given_at' => ['sometimes', 'date', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport given by
|
||||
*
|
||||
* @example Ashgabat shaher polisiya tarapyndan
|
||||
*/
|
||||
'passport_given_by' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Born place
|
||||
*
|
||||
* @example Ashgabat shaher
|
||||
*/
|
||||
'born_place' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Email
|
||||
*
|
||||
* @example mahmyt1206@gmail.com
|
||||
*/
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Phone number (additional)
|
||||
*
|
||||
* @example 61126667
|
||||
*/
|
||||
'phone_additional' => ['nullable', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Phone number (home)
|
||||
*
|
||||
* @example 92-92-92
|
||||
*/
|
||||
'phone_home' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Card number
|
||||
*
|
||||
* @example 4434345434423442
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* Name on card
|
||||
*
|
||||
* @example 'Mahmyt Allaberdiyev'
|
||||
*/
|
||||
'card_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Card expiration month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'card_month' => ['required'],
|
||||
|
||||
/**
|
||||
* Card expiration year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'card_year' => ['required'],
|
||||
|
||||
/**
|
||||
* Card number
|
||||
*
|
||||
* @example 4434345434423442
|
||||
*/
|
||||
'loan_card_number' => ['nullable', 'digits:16'],
|
||||
|
||||
/**
|
||||
* Name on card
|
||||
*
|
||||
* @example 'Mahmyt Allaberdiyev'
|
||||
*/
|
||||
'loan_card_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Card expiration month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'loan_card_month' => ['nullable'],
|
||||
|
||||
/**
|
||||
* Card expiration year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'loan_card_year' => ['nullable'],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'work_region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Provinces (https://online.tbbank.gov.tm/api/provinces)
|
||||
*/
|
||||
'work_province_id' => ['sometimes', 'integer', Rule::exists('provinces', 'id')],
|
||||
|
||||
/**
|
||||
* Work company name
|
||||
*
|
||||
* @example WebUglam HJ
|
||||
*/
|
||||
'work_company' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* HR department number
|
||||
*
|
||||
* @example 707012
|
||||
*/
|
||||
'work_company_accountant_number' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Work position
|
||||
*
|
||||
* @example Bugalter
|
||||
*/
|
||||
'work_position' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Salary
|
||||
*
|
||||
* @example 40000
|
||||
*/
|
||||
'work_salary' => ['sometimes', 'numeric', 'max_digits:8'],
|
||||
|
||||
/**
|
||||
* Work start date
|
||||
*
|
||||
* @example 2024-01-16
|
||||
*/
|
||||
'work_started_at' => ['sometimes', 'date', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* 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'],
|
||||
|
||||
/**
|
||||
* Guarantor name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'guarantor_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor surname
|
||||
*
|
||||
* @example Allaberdiev
|
||||
*/
|
||||
'guarantor_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor surname
|
||||
*
|
||||
* @example Owezowic
|
||||
*/
|
||||
'guarantor_patronic_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor card number
|
||||
*
|
||||
* @example 4323344234423443
|
||||
*/
|
||||
'guarantor_card_number' => ['sometimes', 'string', 'digits:16'],
|
||||
|
||||
/**
|
||||
* Guarantor name on card
|
||||
*
|
||||
* @example Mahmyt Allaberdiyev
|
||||
*/
|
||||
'guarantor_card_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor Card month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'guarantor_card_month' => ['sometimes', 'string'],
|
||||
|
||||
/**
|
||||
* Guarantor Card year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'guarantor_card_year' => ['sometimes', 'string'],
|
||||
|
||||
/**
|
||||
* Guarantor Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'guarantor_passport_serie' => ['sometimes', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Guarantor Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'guarantor_passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'guarantor_2_name' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor surname
|
||||
*
|
||||
* @example Allaberdiev
|
||||
*/
|
||||
'guarantor_2_surname' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor patronic name
|
||||
*
|
||||
* @example Owezowich
|
||||
*/
|
||||
'guarantor_2_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor card number
|
||||
*
|
||||
* @example 4323344234423443
|
||||
*/
|
||||
'guarantor_2_card_number' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', 'digits:16'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor name on card
|
||||
*
|
||||
* @example Mahmyt Allaberdiyev
|
||||
*/
|
||||
'guarantor_2_card_name' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor Card month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'guarantor_2_card_month' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor Card year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'guarantor_2_card_year' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* Guarantor Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'guarantor_2_passport_serie' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Guarantor Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'guarantor_2_passport_id' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'numeric', 'digits:6'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user