diff --git a/app/Http/Controllers/InsuranceInvoiceController.php b/app/Http/Controllers/InsuranceInvoiceController.php index 84ee2ce..1dc33f8 100644 --- a/app/Http/Controllers/InsuranceInvoiceController.php +++ b/app/Http/Controllers/InsuranceInvoiceController.php @@ -145,6 +145,7 @@ class InsuranceInvoiceController extends Controller $query = $query->with(['payments']); } + $query = $query->orderBy('created_at', 'DESC'); if ($pagination) { $invoices = $query->paginate($request->input('perPage', 10)); } else { diff --git a/app/Http/Controllers/InsuredController.php b/app/Http/Controllers/InsuredController.php index f1b217e..d6c7339 100755 --- a/app/Http/Controllers/InsuredController.php +++ b/app/Http/Controllers/InsuredController.php @@ -73,10 +73,14 @@ class InsuredController extends Controller * ref="#/components/schemas/ApiResponse", * example = { * "status" : 200, - * "response" : {{"id":4,"network_id":250,"user_id":349,"insured_id":"GJKS8ZGBEJTL","number_of_months":3,"bonus_amount":"150000.00", - * "number_of_beneficiaries":2,"total_bonus_amount":"495000.00","start_at":"2021-11-11T21:54:02.000000Z","end_at":"2022-02-11T21:54:02.000000Z", - * "state":"PAID","created_at":"2021-11-11T20:54:02.000000Z","updated_at":"2021-11-11T20:54:02.000000Z","user":{"id":349, - * "firstname":null,"lastname":"Tom Di","phone":"+237690716648","email":"ddoubletom@gmail.com"},"network":{"id":250,"name":"Cnamgs-pharmacies"}}}, + * "response" : {{"id":13,"network_id":250,"user_id":348,"insured_id":"PWXVMZNXN39P","months_grid_id":77,"bonus_amount":"50000.00","number_of_beneficiaries":1,"total_bonus_amount":"115000.00","insurance_coverage_amount":"546560.00", + * "start_at":"2022-03-31T00:00:00.000000Z","end_at":"2023-03-31T00:00:00.000000Z","state":"PAID","created_at":"2022-03-31T11:49:07.000000Z","updated_at":"2022-04-12T17:15:26.000000Z","insurance_consumed_amount":"546\u202f560 FCFA","insurance_remaining_amount":"-46\u202f560 FCFA", + * "user":{"id":348,"firstname":null,"lastname":"Manga test 5","phone":"+241074848105","email":"jmangansongo.cfao@yahoo.fr","identification":{"firstname":"","lastname":" Manga test 5","user_image":"U-1606826475.jpg","document_image_front":"D-F-1606826475.jpg", + * "document_image_back":"D-B-1606826475.jpg","id_user":348}},"network":{"id":250,"name":"Cnamgs-pharmacies"},"beneficiaries":{{"id":5,"lastname":"Zele","firstname":"Brice","gender":"M","birthdate":"1997-01-01T00:00:00.000000Z","affiliation":"CHILD","bonus_amount":"65000.00", + * "insurance_coverage_amount":"0.00","birthdate_proof":"CERTIFICATE","birthdate_proof_doc":"NH-e451b9e3-a02b-4f84-b74a-d0028cc814b0.jpg","justice_doc":null,"marriage_certificate_doc":null,"id_document_type":null,"id_document_front":null,"id_document_back":null, + * "profile_image":null,"created_at":"2021-12-01T11:12:27.000000Z","updated_at":"2021-12-01T11:12:27.000000Z","laravel_through_key":13,"insurance_consumed_amount":"0 FCFA","insurance_remaining_amount":"500\u202f000 FCFA","affiliation_tr":"ENFANT"}}, + * "months_grid":{"id":77,"nh_network_config_id":1,"number_of_months":12,"min_amount":35040,"max_insurance_coverage_amount":"500000.00","waiting_period_days":null,"payment_period":"ONE_TIME","payment_duration_months":null,"number_of_fractions":1, + * "created_at":"2022-03-28T22:23:12.000000Z","updated_at":"2022-03-28T22:23:12.000000Z"}}}, * "error":null * } * ) @@ -97,7 +101,8 @@ class InsuredController extends Controller $currency_code = $network->country->currency_code; $datetime = $this->getCurrentTimeByCountryCode($network->country->code_country); - $q = NhInsurance::with(['user:id,firstname,lastname,phone,email', 'network:id,name', 'beneficiaries', 'nhNetworkConfig', 'monthsGrid'])->where('network_id', $network_id) + $q = NhInsurance::with(['user:id,firstname,lastname,phone,email', 'user.identification:firstname,lastname,user_image,document_image_front,document_image_back,id_user', + 'network:id,name', 'beneficiaries', 'nhNetworkConfig', 'monthsGrid'])->where('network_id', $network_id) ->whereIn('state', [InsuranceState::PAID, InsuranceState::PARTIALLY_PAID, InsuranceState::SUSPENDED])->where('start_at', '<=', $datetime); if (!empty($insured_id)) {