added rate to booking table

This commit is contained in:
Jack Goh
2018-06-20 22:54:31 +08:00
parent a30fd2a0b1
commit 385372e3dd
5 changed files with 56 additions and 19 deletions
+4 -1
View File
@@ -17,7 +17,10 @@ class BookingController extends Controller
{
public function index(){
$booking = Booking::where('user_id',Auth::user()->id)->get();
$booking = Booking::select('bookings.id', 'rates.bookings.term')
->leftJoin('rates', 'bookings.rate_id', '=', 'rates.id')
->where('user_id',Auth::user()->id)
->get();
return $booking;
}
@@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddRateToBooking extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('bookings', function (Blueprint $table) {
$table->double('rate')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('bookings', function (Blueprint $table) {
$table->dropColumn('rate');
// $table->dropColumn('reject_reason');
});
}
}
+16 -15
View File
@@ -434,22 +434,23 @@
}
},
mounted(){
axios
.get('/api/booking/')
.then((response) => {
console.log(response)
this.booking.amount = response.data.amount
this.booking.bankin_amount = response.data.bia
this.booking.timeout = response.data.timeout * 1000
this.start = true;
loading.close()
}).catch((error) => {
console.log(error)
loading.close()
this.$router.push({
name: 'notfound'
axios
.get('/api/booking/')
.then((response) => {
this.bookingTable = response
console.log(response)
// this.booking.amount = response.data.amount
// this.booking.bankin_amount = response.data.bia
// this.booking.timeout = response.data.timeout * 1000
// this.start = true;
//loading.close()
}).catch((error) => {
// console.log(error)
// loading.close()
// this.$router.push({
// name: 'notfound'
// })
})
})
},
methods: {
// TODO fetch booking data on load
+2 -2
View File
@@ -26,8 +26,8 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
// return $request->user();
//});
Route::group(['middleware' => 'auth:api'], function () {
Route::post('logout', 'Auth\LoginController@logout');
Route::post('logout', 'Auth\LoginController@logout');
/*Route for the booking */
Route::get('/booking/{book_id}', 'BookingController@show');
Route::put('/booking/{book_id}', 'BookingController@update');
+1 -1
View File
@@ -17,4 +17,4 @@ Route::get('/', 'WelcomeController@index');
Auth::routes();
//Route::get('/home', 'HomeController@index')->name('home');
Route::get('/home', 'HomeController@index')->name('home');