wip
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanOrder\Controllers\Resources;
|
||||
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class LoanOrderShowResource 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,
|
||||
'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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user