Improve getSubscriptions endpoint

This commit is contained in:
Djery-Tom 2021-11-08 07:15:38 +01:00
parent 06f04a887a
commit b046f34019
1 changed files with 4 additions and 4 deletions

View File

@ -689,7 +689,7 @@ class InsuranceSubscriptionController extends Controller
* required=true,
* @OA\Schema(
* type="string",
* enum={"ALL","EDITABLE"}
* enum={"ALL","ACCEPTED"}
* )
* ),
* @OA\Response(
@ -716,7 +716,7 @@ class InsuranceSubscriptionController extends Controller
{
$this->validate($request, [
'user_id' => 'nullable|integer|exists:users,id',
'type' => 'nullable|in:ALL,EDITABLE'
'type' => 'nullable|in:ALL,ACCEPTED'
]);
$user = User::findOrFail($request->input('user_id'));
$currency_code = $user->network->country->currency_code;
@ -728,8 +728,8 @@ class InsuranceSubscriptionController extends Controller
}
if ($request->has('type')) {
$type = $request->input('type');
if ($type == 'EDITABLE') {
$query = $query->whereIn('state', [InsuranceSubscriptionState::UNDER_VALIDATION, InsuranceSubscriptionState::ACCEPTED]);
if ($type != 'ALL') {
$query = $query->whereIn('state', $type);
}
}