mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
upload purchase order
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\PurchaseOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Booking;
|
||||
use App\Rate;
|
||||
@@ -157,6 +158,31 @@ class BookingController extends Controller
|
||||
$post->save();;
|
||||
}
|
||||
|
||||
public function uploadPurchaseOrder(Request $request)
|
||||
{
|
||||
// Handle File Upload
|
||||
if($request->hasFile('image_location')){
|
||||
// Get filename with the extension
|
||||
$filenameWithExt = $request->file('image_location')->getClientOriginalName();
|
||||
// Get just filename
|
||||
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
|
||||
// Get just ext
|
||||
$extension = $request->file('image_location')->getClientOriginalExtension();
|
||||
// Filename to store
|
||||
$fileNameToStore= $filename.'_'.time().'.'.$extension;
|
||||
// Upload Image
|
||||
$path = $request->file('image_location')->storeAs('public/userPurchaseOrder', $fileNameToStore);
|
||||
} else {
|
||||
$fileNameToStore = 'hello.jpg';
|
||||
}
|
||||
// Create Post
|
||||
$post = new PurchaseOrder;
|
||||
$post->amount = $request->input('amount');
|
||||
$post->book_id = $request->input('book_id');
|
||||
$post->image_location = $fileNameToStore;
|
||||
$post->save();;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
|
||||
Reference in New Issue
Block a user