From a6508799778f61140df057eda49fd306c477100d Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 21 Jun 2018 10:43:52 +0800 Subject: [PATCH] completed list booking TBD implement status feature --- app/Http/Controllers/BookingController.php | 23 +++++++++++++-- resources/assets/js/pages/home.vue | 33 +++++++++++----------- routes/web.php | 8 +++--- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 19a75a61..48739040 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -17,11 +17,28 @@ class BookingController extends Controller { public function index(){ - $booking = Booking::select('bookings.id', 'rates.bookings.term') - ->leftJoin('rates', 'bookings.rate_id', '=', 'rates.id') + $bookings = Booking::select('id', 'created_at', 'rate', 'amount', 'bia', 'verification_status') ->where('user_id',Auth::user()->id) ->get(); - return $booking; + + // reformat to fit frontend structure + foreach ($bookings as $booking) { + // set timeout + $date1 = new DateTime($booking->created_at); + $date2 = new DateTime(); + $difference_in_seconds = ($date1->format('U') + 600) - ($date2->format('U')); + $booking->timeout = $difference_in_seconds; + + // TODO : transfer_amount change name to bia + $booking->transfer_amount = $booking->bia; + + // TODO : Logic for status + $booking->track_status = "1/1"; + $booking->status_desc = "hello"; + $booking->status = 6; + } + + return $bookings; } public function show($id) diff --git a/resources/assets/js/pages/home.vue b/resources/assets/js/pages/home.vue index 7d9d464c..06308f43 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -239,11 +239,11 @@
- + Update - {{scope.row.booking_no}} + {{scope.row.id}} - + @@ -354,8 +354,8 @@ dialogFormVisible1: false, formLabelWidth: '0px', bookingTable: [{ - date: '12/1/2018', - booking_no: '12', + created_at: '12/1/2018', + id: '12', rate: '1.23', amount: 'RM 1000', transfer_amount: 'RMB 10000', @@ -365,8 +365,8 @@ status: 2 }, { - date: '12/1/2018', - booking_no: '13', + created_at: '12/1/2018', + id: '13', rate: '1.23', amount: 'RM 1000', transfer_amount: 'RMB 10000', @@ -376,8 +376,8 @@ status: 3 }, { - date: '12/1/2018', - booking_no: '14', + created_at: '12/1/2018', + id: '14', rate: '1.23', amount: 'RM 1000', transfer_amount: 'RMB 10000', @@ -387,8 +387,8 @@ status: 4 }, { - date: '12/1/2018', - booking_no: '15', + created_at: '12/1/2018', + id: '15', rate: '1.23', amount: 'RM 1000', transfer_amount: 'RMB 10000', @@ -398,8 +398,8 @@ status: 5 }, { - date: '12/1/2018', - booking_no: '16', + created_at: '12/1/2018', + id: '16', rate: '1.23', amount: 'RM 1000', transfer_amount: 'RMB 10000', @@ -409,8 +409,8 @@ status: 6 }, { - date: '12/1/2018', - booking_no: '17', + created_at: '12/1/2018', + id: '17', rate: '1.23', amount: 'RM 1000', transfer_amount: 'RMB 10000', @@ -437,8 +437,9 @@ axios .get('/api/booking/') .then((response) => { - this.bookingTable = response console.log(response) + this.bookingTable = response.data + // this.booking.amount = response.data.amount // this.booking.bankin_amount = response.data.bia // this.booking.timeout = response.data.timeout * 1000 diff --git a/routes/web.php b/routes/web.php index 9b72ec26..7dc992f7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,10 +11,10 @@ | */ Route::get('/', 'WelcomeController@index'); -//Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request'); -//Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset'); -//Route::get('{path}', 'WelcomeController@index')->where('path', '(.*)'); +Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request'); +Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset'); +Route::get('{path}', 'WelcomeController@index')->where('path', '(.*)'); Auth::routes(); -Route::get('/home', 'HomeController@index')->name('home'); +//Route::get('/home', 'WelcomeController@index')->name('home');