update status to 7 on approve

This commit is contained in:
Edmond Teh
2020-09-06 16:07:45 +08:00
parent 96a08b6839
commit ef156ecde4
+17 -2
View File
@@ -263,7 +263,7 @@ class InvoiceController extends Controller
'comment' => Rule::requiredIf($request->status === 'request_change')
]);
// Save to database
// Save status to database
$status = new InvoiceStatuses;
$status->status = $validatedData['status'];
@@ -271,8 +271,23 @@ class InvoiceController extends Controller
$status->invoice_id = Invoice::where('booking_id', $id)->first()['id'];
$status->save();
// Response
if(!$status) {
return response()->json(['message' => 'Unable to Update Status'], 500);
}
// Change Status to 7 if approve
if ($validatedData['status'] === 'approve') {
$booking = Booking::find($id);
$booking->status = 7;
$booking->admin_status = 7;
$booking->save();
if(!$booking) {
return response()->json(['message' => 'Unable to Complete Booking. Please Approve Again'], 500);
}
}
// Response
return response()->json($status, 201);