fix apis
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Modules\LoanOrder\Controllers\Resources\LoanOrderIndexResource;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LoanOrderController extends Controller
|
||||
{
|
||||
@@ -18,29 +19,46 @@ class LoanOrderController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json(LoanOrderIndexResource::collection(
|
||||
LoanOrder::query()->where('user_id', auth()->id())->paginate()
|
||||
LoanOrder::query()
|
||||
->where('user_id', auth()->id())
|
||||
->where('source', OrderRepo::MOBILE_DEVICE)
|
||||
->paginate()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE* Loan order.
|
||||
*/
|
||||
public function store(LoanOrderStoreRequest $request): JsonResponse
|
||||
public function store(LoanOrderStoreRequest $request)
|
||||
{
|
||||
LoanOrder::create(
|
||||
$request->validated(),
|
||||
LoanOrder::forceCreate([
|
||||
...$request->validated(),
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
'status' => OrderRepo::PENDING,
|
||||
'source' => OrderRepo::MOBILE_DEVICE,
|
||||
]
|
||||
);
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload files
|
||||
*/
|
||||
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/'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
||||
@@ -301,14 +301,14 @@ class LoanOrderStoreRequest extends FormRequest
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'guarantor_2_name' => ['required', 'string', 'max:255'],
|
||||
'guarantor_2_name' => [Rule::requiredIf($this->loan_amount > 20000), 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor surname
|
||||
*
|
||||
* @example Allaberdiev
|
||||
*/
|
||||
'guarantor_2_surname' => ['required', 'string', 'max:255'],
|
||||
'guarantor_2_surname' => [Rule::requiredIf($this->loan_amount > 20000), 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor patronic name
|
||||
@@ -322,28 +322,28 @@ class LoanOrderStoreRequest extends FormRequest
|
||||
*
|
||||
* @example 4323344234423443
|
||||
*/
|
||||
'guarantor_2_card_number' => ['required', 'string', 'digits:16'],
|
||||
'guarantor_2_card_number' => [Rule::requiredIf($this->loan_amount > 20000), 'string', 'digits:16'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor name on card
|
||||
*
|
||||
* @example Mahmyt Allaberdiyev
|
||||
*/
|
||||
'guarantor_2_card_name' => ['required', 'string'],
|
||||
'guarantor_2_card_name' => [Rule::requiredIf($this->loan_amount > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor Card month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'guarantor_2_card_month' => ['required', 'string'],
|
||||
'guarantor_2_card_month' => [Rule::requiredIf($this->loan_amount > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor Card year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'guarantor_2_card_year' => ['required', 'string'],
|
||||
'guarantor_2_card_year' => [Rule::requiredIf($this->loan_amount > 20000), 'string'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ class OrderRepo
|
||||
public static function statusValues(): array
|
||||
{
|
||||
return [
|
||||
'' => '',
|
||||
null => '',
|
||||
null => '-',
|
||||
self::PENDING => __('Pending'),
|
||||
self::REGISTER => __('Registered'),
|
||||
self::PROCESSING => __('Processing'),
|
||||
@@ -68,6 +67,7 @@ class OrderRepo
|
||||
public static function statusClasses(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
self::PENDING => 'warning',
|
||||
self::REGISTER => 'info',
|
||||
self::PROCESSING => 'primary',
|
||||
@@ -84,6 +84,7 @@ class OrderRepo
|
||||
public static function statusIcons(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
'success' => 'check-circle',
|
||||
'info' => 'information-circle',
|
||||
'primary' => 'clipboard-list',
|
||||
@@ -100,6 +101,7 @@ class OrderRepo
|
||||
public static function statusColors(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
self::PENDING => '#F5573B',
|
||||
self::REGISTER => '#F2CB22',
|
||||
self::PROCESSING => '#8FC15D',
|
||||
|
||||
Reference in New Issue
Block a user