@@ -85,7 +85,7 @@ public function store(StorePayBillRequest $request): JsonResponse
85
85
'country_id ' => $ request ->input ('source_country_id ' , $ depositor ->profile ?->country_id),
86
86
])->first ();
87
87
88
- if (! $ depositAccount ) {
88
+ if (!$ depositAccount ) {
89
89
throw new Exception ("User don't have account deposit balance " );
90
90
}
91
91
@@ -94,8 +94,8 @@ public function store(StorePayBillRequest $request): JsonResponse
94
94
'country_id ' => $ request ->input ('source_country_id ' , $ depositor ->profile ?->country_id),
95
95
])->first ();
96
96
97
- if (! $ masterUser ) {
98
- throw new Exception ('Master User Account not found for ' . $ request ->input ('source_country_id ' , $ depositor ->profile ?->country_id). ' country ' );
97
+ if (!$ masterUser ) {
98
+ throw new Exception ('Master User Account not found for ' . $ request ->input ('source_country_id ' , $ depositor ->profile ?->country_id) . ' country ' );
99
99
}
100
100
101
101
//set pre defined conditions of deposit
@@ -125,7 +125,7 @@ public function store(StorePayBillRequest $request): JsonResponse
125
125
126
126
$ payBill = Tab::payBill ()->create ($ inputs );
127
127
128
- if (! $ payBill ) {
128
+ if (!$ payBill ) {
129
129
throw (new StoreOperationException )->setModel (config ('fintech.tab.pay_bill_model ' ));
130
130
}
131
131
$ order_data = $ payBill ->order_data ;
@@ -141,20 +141,20 @@ public function store(StorePayBillRequest $request): JsonResponse
141
141
])->first ();
142
142
//update User Account
143
143
$ depositedUpdatedAccount = $ depositedAccount ->toArray ();
144
- $ depositedUpdatedAccount ['user_account_data ' ]['spent_amount ' ] = (float ) $ depositedUpdatedAccount ['user_account_data ' ]['spent_amount ' ] + (float ) $ userUpdatedBalance ['spent_amount ' ];
145
- $ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ] = (float ) $ userUpdatedBalance ['current_amount ' ];
146
- if (((float ) $ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ]) < ((float ) config ('fintech.transaction.minimum_balance ' ))) {
144
+ $ depositedUpdatedAccount ['user_account_data ' ]['spent_amount ' ] = (float )$ depositedUpdatedAccount ['user_account_data ' ]['spent_amount ' ] + (float )$ userUpdatedBalance ['spent_amount ' ];
145
+ $ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ] = (float )$ userUpdatedBalance ['current_amount ' ];
146
+ if (((float )$ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ]) < ((float )config ('fintech.transaction.minimum_balance ' ))) {
147
147
throw new Exception (__ ('Insufficient balance! ' , [
148
- 'previous_amount ' => ((float ) $ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ]),
149
- 'current_amount ' => ((float ) $ userUpdatedBalance ['spent_amount ' ]),
148
+ 'previous_amount ' => ((float )$ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ]),
149
+ 'current_amount ' => ((float )$ userUpdatedBalance ['spent_amount ' ]),
150
150
]));
151
151
}
152
- $ order_data ['order_data ' ]['previous_amount ' ] = (float ) $ depositedAccount ->user_account_data ['available_amount ' ];
153
- $ order_data ['order_data ' ]['current_amount ' ] = (float ) $ userUpdatedBalance ['current_amount ' ];
154
- if (! Transaction::userAccount ()->update ($ depositedAccount ->getKey (), $ depositedUpdatedAccount )) {
152
+ $ order_data ['order_data ' ]['previous_amount ' ] = (float )$ depositedAccount ->user_account_data ['available_amount ' ];
153
+ $ order_data ['order_data ' ]['current_amount ' ] = (float )$ userUpdatedBalance ['current_amount ' ];
154
+ if (!Transaction::userAccount ()->update ($ depositedAccount ->getKey (), $ depositedUpdatedAccount )) {
155
155
throw new Exception (__ ('User Account Balance does not update ' , [
156
- 'previous_amount ' => ((float ) $ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ]),
157
- 'current_amount ' => ((float ) $ userUpdatedBalance ['spent_amount ' ]),
156
+ 'previous_amount ' => ((float )$ depositedUpdatedAccount ['user_account_data ' ]['available_amount ' ]),
157
+ 'current_amount ' => ((float )$ userUpdatedBalance ['spent_amount ' ]),
158
158
]));
159
159
}
160
160
Tab::payBill ()->update ($ payBill ->getKey (), ['order_data ' => $ order_data , 'order_number ' => $ order_data ['purchase_number ' ]]);
@@ -179,23 +179,28 @@ public function store(StorePayBillRequest $request): JsonResponse
179
179
180
180
/**
181
181
* @lrd:start
182
- * Return a specified *PayBill* resource found by id.
182
+ * Update a specified *PayBill* resource using id.
183
183
*
184
184
* @lrd:end
185
- *
186
- * @throws ModelNotFoundException
187
185
*/
188
- public function show ( string |int $ id ): PayBillResource | JsonResponse
186
+ public function update ( UpdatePayBillRequest $ request , string |int $ id ): JsonResponse
189
187
{
190
188
try {
191
189
192
190
$ payBill = Tab::payBill ()->find ($ id );
193
191
194
- if (! $ payBill ) {
192
+ if (!$ payBill ) {
195
193
throw (new ModelNotFoundException )->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
196
194
}
197
195
198
- return new PayBillResource ($ payBill );
196
+ $ inputs = $ request ->validated ();
197
+
198
+ if (!Tab::payBill ()->update ($ id , $ inputs )) {
199
+
200
+ throw (new UpdateOperationException )->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
201
+ }
202
+
203
+ return $ this ->updated (__ ('core::messages.resource.updated ' , ['model ' => 'Pay Bill ' ]));
199
204
200
205
} catch (ModelNotFoundException $ exception ) {
201
206
@@ -209,28 +214,23 @@ public function show(string|int $id): PayBillResource|JsonResponse
209
214
210
215
/**
211
216
* @lrd:start
212
- * Update a specified *PayBill* resource using id.
217
+ * Return a specified *PayBill* resource found by id.
213
218
*
214
219
* @lrd:end
220
+ *
221
+ * @throws ModelNotFoundException
215
222
*/
216
- public function update ( UpdatePayBillRequest $ request , string |int $ id ): JsonResponse
223
+ public function show ( string |int $ id ): PayBillResource | JsonResponse
217
224
{
218
225
try {
219
226
220
227
$ payBill = Tab::payBill ()->find ($ id );
221
228
222
- if (! $ payBill ) {
229
+ if (!$ payBill ) {
223
230
throw (new ModelNotFoundException )->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
224
231
}
225
232
226
- $ inputs = $ request ->validated ();
227
-
228
- if (! Tab::payBill ()->update ($ id , $ inputs )) {
229
-
230
- throw (new UpdateOperationException )->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
231
- }
232
-
233
- return $ this ->updated (__ ('core::messages.resource.updated ' , ['model ' => 'Pay Bill ' ]));
233
+ return new PayBillResource ($ payBill );
234
234
235
235
} catch (ModelNotFoundException $ exception ) {
236
236
@@ -254,11 +254,11 @@ public function destroy(string|int $id): JsonResponse
254
254
255
255
$ payBill = Tab::payBill ()->find ($ id );
256
256
257
- if (! $ payBill ) {
257
+ if (!$ payBill ) {
258
258
throw (new ModelNotFoundException )->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
259
259
}
260
260
261
- if (! Tab::payBill ()->destroy ($ id )) {
261
+ if (!Tab::payBill ()->destroy ($ id )) {
262
262
263
263
throw (new DeleteOperationException ())->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
264
264
}
@@ -288,11 +288,11 @@ public function restore(string|int $id): JsonResponse
288
288
289
289
$ payBill = Tab::payBill ()->find ($ id , true );
290
290
291
- if (! $ payBill ) {
291
+ if (!$ payBill ) {
292
292
throw (new ModelNotFoundException )->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
293
293
}
294
294
295
- if (! Tab::payBill ()->restore ($ id )) {
295
+ if (!Tab::payBill ()->restore ($ id )) {
296
296
297
297
throw (new RestoreOperationException ())->setModel (config ('fintech.tab.pay_bill_model ' ), $ id );
298
298
}
0 commit comments