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