From 6d2c83d912e638e92b33d340e23c8364940bfb72 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 28 Jun 2018 15:38:15 +0800 Subject: [PATCH] temporary added default amount value fixed no file detected bug --- app/Http/Controllers/BookingController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 30a650a5..1bef639e 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -610,7 +610,7 @@ class BookingController extends Controller return response()->json(['message'=>'Image too large, upload files up to 3 MB'], 400); } - if(!$input_file = $request->file('invoice_path')) + if(!$input_file = $request->file('file')) { return response()->json(['message'=>'No file detected'], 400); } @@ -619,16 +619,16 @@ class BookingController extends Controller $filename = $input_file->getClientOriginalName(); $ext = $input_file->getClientOriginalExtension(); - $input['invoice_path'] = $filename; $unique_name = 'invoice' . md5($filename. time()); $unique_file_url = $unique_name. '.' .$ext; $upload_path = Storage::disk('public')->putFileAs( - 'invoice',/*folder name*/ $input_file, $unique_file_url, 'public' + 'invoice', $input_file, $unique_file_url, 'public' ); $invoice = new Invoice; $invoice->invoice_path = $upload_path; - $invoice->amount = $request->input('amount'); + // TODO : amount + $invoice->amount = 0; $invoice->booking_id = $booking->id; $invoice->save(); @@ -664,14 +664,14 @@ class BookingController extends Controller { $booking = Booking::where('id', $id)->firstOrFail(); - $invoice = $booking->invoice()->first; + $invoice = $booking->invoice()->first(); if(!$invoice){ return response()->json(["message"=> "Please upload your invoice"],400); } - $booking->status = 7; // processing transfer - $booking->admin_status = 6; // upload china bankslip + $booking->status = 7; // completed + $booking->admin_status = 7; // completed if($booking->save()){ return response()->json(['message'=>"Success"],200);