mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
added booking foreign key to china bankslip
updated upload china bankslip routes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\ChinaBankSlip;
|
||||
use App\Booking;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Validator;
|
||||
@@ -10,8 +11,10 @@ use Validator;
|
||||
class ChinaBankSlipController extends Controller
|
||||
{
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
public function store(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('id',$id)->firstOrFail();
|
||||
|
||||
// TODO : put this after check file exist
|
||||
// validate file format
|
||||
$validator = Validator::make($request->all(), [
|
||||
@@ -34,7 +37,7 @@ class ChinaBankSlipController extends Controller
|
||||
}
|
||||
|
||||
|
||||
if($bankslip_file = $request->hasFile('china_slip_file')){
|
||||
if($bankslip_file = $request->file('file')){
|
||||
|
||||
$filename = $bankslip_file->getClientOriginalName();
|
||||
$ext = $bankslip_file->getClientOriginalExtension();
|
||||
@@ -52,12 +55,10 @@ class ChinaBankSlipController extends Controller
|
||||
}
|
||||
|
||||
$china_bankslip = new ChinaBankSlip;
|
||||
$china_bankslip ->actual_transfer_amount = $request->input('actual_transfer_amount');
|
||||
$china_bankslip ->date = $request->input('date');
|
||||
$china_bankslip ->details = $request->input('details');
|
||||
$china_bankslip ->china_bank_slip_path = $fileNameToStore;
|
||||
$china_bankslip ->save();
|
||||
|
||||
$china_bankslip->booking_id = $booking->id;
|
||||
$china_bankslip->china_bank_slip_path = $upload_path;
|
||||
$china_bankslip->save();
|
||||
|
||||
return response()->json(['message'=>'success'], 201);
|
||||
}
|
||||
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBookingidForeignkeyToChinabankslipTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('china_bank_slips', function($table)
|
||||
{
|
||||
$table->integer('booking_id')->unsigned();
|
||||
$table->foreign('booking_id')->references('id')->on('bookings');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -205,10 +205,9 @@
|
||||
<div align="center">
|
||||
|
||||
<!-- upload image -->
|
||||
<el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/"
|
||||
<el-upload class="upload-demo" :action="'/api/booking/' + booking_id + '/upload-china-bankslip'"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
:file-list="fileList2"
|
||||
:on-remove="handleRemove"
|
||||
:multiple="false"
|
||||
list-type="picture">
|
||||
<el-button size="small" type="primary">Click to upload</el-button>
|
||||
@@ -258,6 +257,7 @@
|
||||
return {
|
||||
status: 5,
|
||||
loading_btn: false,
|
||||
booking_id: this.$route.params.id,
|
||||
booking_details: {
|
||||
id: null,
|
||||
amount: null,
|
||||
|
||||
+3
-3
@@ -44,10 +44,10 @@ Route::group(['middleware' => 'auth:api'], function () {
|
||||
Route::post('booking/{book_id}/cancel', 'BookingController@cancel');
|
||||
Route::get('/booking', 'BookingController@index');
|
||||
Route::get('/user', 'UserController@show');
|
||||
});
|
||||
|
||||
Route::patch('settings/profile', 'Settings\ProfileController@update');
|
||||
Route::patch('settings/password', 'Settings\PasswordController@update');
|
||||
});
|
||||
|
||||
|
||||
|
||||
Route::group(['middleware' => 'guest:api'], function () {
|
||||
@@ -101,7 +101,7 @@ Route::group(['middleware' => ['role:admin']], function() {
|
||||
Route::post('supplier-booking', 'BookingSupplierController@store');
|
||||
Route::put('supplier-booking/{id}', 'BookingSupplierController@update');
|
||||
|
||||
Route::post('upload-china-bankslip', 'ChinaBankSlipController@store');
|
||||
Route::post('/booking/{id}/upload-china-bankslip','ChinaBankSlipController@store');
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user