upload purchase order

This commit is contained in:
Nazri
2018-05-28 17:24:13 +08:00
parent 5c1a4d28c4
commit 4210cdc19d
9 changed files with 118 additions and 13 deletions
@@ -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.