Improve getSubscriptions endpoint
This commit is contained in:
parent
06f04a887a
commit
b046f34019
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue