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