mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-23 22:34:19 +00:00
rename image_url to image_path in user_bank_slip,invoice,purchase_order
This commit is contained in:
@@ -224,14 +224,14 @@ class BookingController extends Controller
|
||||
$input['file'] = $filename;
|
||||
|
||||
$unique_name = 'bank_slip_' . md5($filename. time()); // probably not a good idea
|
||||
$unique_image_url = $unique_name. '.' .$ext;
|
||||
$unique_image_path = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'user_bankslip', $bankslip_file, $unique_image_url
|
||||
'user_bankslip', $bankslip_file, $unique_image_path
|
||||
);
|
||||
|
||||
$user_bankslip = new UserBankSlip;
|
||||
$user_bankslip->booking_id = $booking->id;
|
||||
$user_bankslip->bankslip_url = $unique_image_url;
|
||||
$user_bankslip->bankslip_path = $unique_image_path;
|
||||
$user_bankslip->transfer_amount = $request->input('transfer_amount');
|
||||
$user_bankslip->save();
|
||||
|
||||
@@ -281,13 +281,13 @@ class BookingController extends Controller
|
||||
|
||||
$input['file'] = $filename;
|
||||
$unique_name = 'purchase_order_' . md5($filename. time());
|
||||
$unique_image_url = $unique_name. '.' .$ext;
|
||||
$unique_image_path = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'purchase_order',/*folder name*/ $user_input_file, $unique_image_url
|
||||
'purchase_order',/*folder name*/ $user_input_file, $unique_image_path
|
||||
);
|
||||
|
||||
$user_po = new PurchaseOrder;
|
||||
$user_po->image_url = $unique_image_url;
|
||||
$user_po->image_path = $unique_image_path;
|
||||
$user_po->book_id = $booking->id;
|
||||
$user_po->amount = $request->input('amount');
|
||||
$user_po->save();
|
||||
@@ -437,7 +437,7 @@ class BookingController extends Controller
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'invoice_url' => 'mimes:jpg,jpeg,bmp,png,pdf,doc,docx'
|
||||
'invoice_path' => 'mimes:jpg,jpeg,bmp,png,pdf,doc,docx'
|
||||
]);
|
||||
|
||||
if($validator->fails())
|
||||
@@ -445,7 +445,7 @@ class BookingController extends Controller
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
}
|
||||
|
||||
if(!$input_file = $request->file('invoice_url'))
|
||||
if(!$input_file = $request->file('invoice_path'))
|
||||
{
|
||||
return response()->json(['message'=>'No file detected'], 400);
|
||||
}
|
||||
@@ -454,7 +454,7 @@ class BookingController extends Controller
|
||||
$filename = $input_file->getClientOriginalName();
|
||||
$ext = $input_file->getClientOriginalExtension();
|
||||
|
||||
$input['invoice_url'] = $filename;
|
||||
$input['invoice_path'] = $filename;
|
||||
$unique_name = 'invoice' . md5($filename. time());
|
||||
$unique_file_url = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
@@ -462,7 +462,7 @@ class BookingController extends Controller
|
||||
);
|
||||
|
||||
$invoice = new Invoice;
|
||||
$invoice->invoice_url = $unique_file_url;
|
||||
$invoice->invoice_path = $unique_file_url;
|
||||
$invoice->amount = $request->input('amount');
|
||||
$invoice->booking_id = $booking->id;
|
||||
$invoice->save();
|
||||
|
||||
@@ -7,7 +7,7 @@ $factory->define(App\UserBankSlip::class, function (Faker $faker) {
|
||||
|
||||
return [
|
||||
'bank_slip_type' => str_random(10),
|
||||
'bankslip_url' => str_random(10),
|
||||
'bankslip_path' => str_random(10),
|
||||
'transfer_amount' => $faker->randomDigit,
|
||||
'cust_marking' => str_random(10),
|
||||
'booking_id' => $faker->randomElement($book_id),
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateInvoiceTable extends Migration
|
||||
{
|
||||
Schema::create('invoices', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('invoice_url');
|
||||
$table->string('invoice_path');
|
||||
$table->double('amount');
|
||||
$table->integer('booking_id')->unsigned();
|
||||
$table->foreign('booking_id')->references('id')->on('bookings');
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenameImageurlToImagepathInUserbankslipsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('user_bank_slips', function($table)
|
||||
{
|
||||
$table->renameColumn('bankslip_url', 'bankslip_path');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenameImageurlToImagepathInPurchaseordersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('purchase_orders', function($table)
|
||||
{
|
||||
$table->renameColumn('image_url', 'image_path');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -74,15 +74,15 @@ class BookingTest extends TestCase
|
||||
public function testuploadbankslip()
|
||||
{
|
||||
Storage::fake('file');
|
||||
$bankslip_url = UploadedFile::fake()->image('comp.jpg');
|
||||
$bankslip_path = UploadedFile::fake()->image('comp.jpg');
|
||||
|
||||
if(!file_exists($bankslip_url)){
|
||||
if(!file_exists($bankslip_path)){
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->json('POST', '/api/booking/' . $this->booking->id . '/upload-user-bankslip', [
|
||||
'file' => $bankslip_url
|
||||
'file' => $bankslip_path
|
||||
])
|
||||
->assertSuccessful();
|
||||
}
|
||||
@@ -98,16 +98,16 @@ class BookingTest extends TestCase
|
||||
|
||||
public function testuploadPO()
|
||||
{
|
||||
Storage::fake('image_url');
|
||||
$image_url = UploadedFile::fake()->image('comp.jpg');
|
||||
Storage::fake('file');
|
||||
$image_path = UploadedFile::fake()->image('comp.jpg');
|
||||
|
||||
if(!file_exists($image_url)){
|
||||
if(!file_exists($image_path)){
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->json('POST', '/api/booking/' . $this->booking->id . '/upload-po', [
|
||||
'file' => $image_url,
|
||||
'file' => $image_path,
|
||||
'amount' => '12345'
|
||||
])
|
||||
->assertSuccessful();
|
||||
@@ -141,16 +141,16 @@ class BookingTest extends TestCase
|
||||
$this->user->roles()->sync([]);
|
||||
$this->user->attachRole(Role::Where('name','admin')->first());
|
||||
|
||||
Storage::fake('invoice_url');
|
||||
$invoice_url = UploadedFile::fake()->create('document.pdf');
|
||||
Storage::fake('invoice_path');
|
||||
$invoice_path = UploadedFile::fake()->create('document.pdf');
|
||||
|
||||
if(!file_exists($invoice_url)){
|
||||
if(!file_exists($invoice_path)){
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->json('POST', '/api/booking/' . $this->booking->id . '/upload-invoice', [
|
||||
'invoice_url' => $invoice_url,
|
||||
'invoice_path' => $invoice_path,
|
||||
'amount' => '12345'
|
||||
])
|
||||
->assertSuccessful();
|
||||
|
||||
Reference in New Issue
Block a user