From 139d1302159e8b406f32471033e13f5c631b64be Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Thu, 26 Sep 2024 15:34:48 +0500 Subject: [PATCH] wip --- app/Models/Order/Loan/LoanOrder.php | 2 +- .../Controllers/LoanOrderController.php | 7 +- .../Resources/LoanOrderShowResource.php | 85 +++++++++++++++++++ 3 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php diff --git a/app/Models/Order/Loan/LoanOrder.php b/app/Models/Order/Loan/LoanOrder.php index 237daef..8510704 100644 --- a/app/Models/Order/Loan/LoanOrder.php +++ b/app/Models/Order/Loan/LoanOrder.php @@ -94,7 +94,7 @@ class LoanOrder extends Model */ public function workProvince(): BelongsTo { - return $this->belongsTo(Province::class, 'province_id'); + return $this->belongsTo(Province::class, 'work_province_id'); } /** diff --git a/app/Modules/LoanOrder/Controllers/LoanOrderController.php b/app/Modules/LoanOrder/Controllers/LoanOrderController.php index 86c2465..627e576 100644 --- a/app/Modules/LoanOrder/Controllers/LoanOrderController.php +++ b/app/Modules/LoanOrder/Controllers/LoanOrderController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Models\Order\Loan\LoanOrder; 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 Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -60,11 +61,11 @@ class LoanOrderController extends Controller } /** - * Display the specified resource. + * SHOW* Loan order */ - public function show(Request $request): void + public function show(LoanOrder $loanOrder) { - // + return response()->json(new LoanOrderShowResource($loanOrder)); } /** diff --git a/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php b/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php new file mode 100644 index 0000000..253fdf4 --- /dev/null +++ b/app/Modules/LoanOrder/Controllers/Resources/LoanOrderShowResource.php @@ -0,0 +1,85 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'unique_id' => $this->unique_id, + 'loan_amount' => $this->loan_amount, + 'loan_type' => $this->loanType?->name, + 'region' => RegionRepo::label($this->region), + 'branch' => $this->branch?->name, + 'customer_name' => $this->customer_name, + 'customer_surname' => $this->customer_surname, + 'customer_patronic_name' => $this->customer_patronic_name, + 'passport_address' => $this->passport_address, + 'real_address' => $this->real_address, + 'passport_serie' => $this->passport_serie, + 'passport_id' => $this->passport_id, + 'passport_given_at' => $this->passport_given_at, + 'passport_given_by' => $this->passport_given_by, + 'born_place' => $this->born_place, + 'born_at' => $this->born_at, + 'email' => $this->email, + 'phone' => $this->phone, + 'phone_additional' => $this->phone_additional, + 'phone_home' => $this->phone_home, + 'work_region' => RegionRepo::label($this->work_region), + 'work_province' => $this->workProvince?->name, + 'work_company' => $this->work_company, + 'work_company_accountant_number' => $this->work_company_accountant_number, + 'work_started_at' => $this->work_started_at, + 'work_salary' => $this->work_salary, + 'work_position' => $this->work_position, + 'education' => EducationRepo::values()[$this->education] ?? '-', + 'marriage_status' => MarriageRepo::values()[$this->marriage_status] ?? '-', + 'passport_one' => url(Storage::url($this->passport_one)), + 'passport_two' => url(Storage::url($this->passport_two)), + 'passport_three' => url(Storage::url($this->passport_three)), + 'passport_four' => url(Storage::url($this->passport_four)), + 'card_number' => $this->card_number, + 'card_name' => $this->card_name, + 'card_month' => $this->card_month, + 'card_year' => $this->card_year, + 'guarantor_name' => $this->guarantor_name, + 'guarantor_surname' => $this->guarantor_surname, + 'guarantor_patronic_name' => $this->guarantor_patronic_name, + 'guarantor_card_number' => $this->guarantor_card_number, + 'guarantor_card_name' => $this->guarantor_card_name, + 'guarantor_card_month' => $this->guarantor_card_month, + 'guarantor_card_year' => $this->guarantor_card_year, + 'guarantor_2_name' => $this->guarantor_2_name, + 'guarantor_2_surname' => $this->guarantor_2_surname, + 'guarantor_2_patronic_name' => $this->guarantor_2_patronic_name, + 'guarantor_2_card_number' => $this->guarantor_2_card_number, + 'guarantor_2_card_name' => $this->guarantor_2_card_name, + 'guarantor_2_card_month' => $this->guarantor_2_card_month, + 'guarantor_2_card_year' => $this->guarantor_2_card_year, + 'guarantor_note' => $this->guarantor_note, + 'guarantor_2_note' => $this->guarantor_2_note, + 'satisfiable' => $this->satisfiable, + + 'status' => OrderRepo::statusFormatted($this->status), + 'notes' => $this->notes, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]; + } +}