added form entertaiment and fix file upload
This commit is contained in:
@@ -12,6 +12,8 @@ use App\Models\Region;
|
||||
use App\Models\Cabang;
|
||||
use App\Models\UserHasCabang;
|
||||
use App\Models\Kategori;
|
||||
use App\Helpers\NextCloudHelper;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FormVehicleController extends Controller
|
||||
{
|
||||
@@ -56,20 +58,42 @@ class FormVehicleController extends Controller
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle/';
|
||||
|
||||
// check if folder not exists
|
||||
// if (!Storage::disk('nextcloud')->exists(trim($folderPath, '/'))) {
|
||||
// Storage::disk('nextcloud')->makeDirectory(trim($folderPath, '/'));
|
||||
// }
|
||||
if ($request->hasFile('bukti1')) {
|
||||
$bukti1 = $request->file('bukti1');
|
||||
$filename = Str::uuid() . '.' . $bukti1->extension();
|
||||
|
||||
$filePaths['bukti1'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti1->getContent(),
|
||||
$filename
|
||||
);
|
||||
|
||||
// Store files to Nextcloud and collect their paths
|
||||
if ($request->hasFile('bukti1')) {
|
||||
$filePaths['bukti1'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti1'), $request->file('bukti1')->getClientOriginalName());
|
||||
}
|
||||
if ($request->hasFile('bukti2')) {
|
||||
$filePaths['bukti2'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti2'), $request->file('bukti2')->getClientOriginalName());
|
||||
$bukti2 = $request->file('bukti2');
|
||||
$filename = Str::uuid() . '.' . $bukti2->extension();
|
||||
|
||||
$filePaths['bukti2'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti2->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
if ($request->hasFile('bukti3')) {
|
||||
$filePaths['bukti3'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti3'), $request->file('bukti3')->getClientOriginalName());
|
||||
$bukti3 = $request->file('bukti3');
|
||||
$filename = Str::uuid() . '.' . $bukti3->extension();
|
||||
|
||||
$filePaths['bukti3'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti3->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
|
||||
// Generate sequence number and expense number
|
||||
@@ -133,20 +157,42 @@ class FormVehicleController extends Controller
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/vehicle/';
|
||||
|
||||
// check if folder not exists
|
||||
// if (!Storage::disk('nextcloud')->exists(trim($folderPath, '/'))) {
|
||||
// Storage::disk('nextcloud')->makeDirectory(trim($folderPath, '/'));
|
||||
// }
|
||||
|
||||
// Store files to Nextcloud and collect their paths
|
||||
if ($request->hasFile('bukti1')) {
|
||||
$filePaths['bukti1'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti1'), $request->file('bukti1')->getClientOriginalName());
|
||||
$bukti1 = $request->file('bukti1');
|
||||
$filename = Str::uuid() . '.' . $bukti1->extension();
|
||||
|
||||
$filePaths['bukti1'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti1->getContent(),
|
||||
$filename
|
||||
);
|
||||
|
||||
}
|
||||
if ($request->hasFile('bukti2')) {
|
||||
$filePaths['bukti2'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti2'), $request->file('bukti2')->getClientOriginalName());
|
||||
$bukti2 = $request->file('bukti2');
|
||||
$filename = Str::uuid() . '.' . $bukti2->extension();
|
||||
|
||||
$filePaths['bukti2'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti2->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
if ($request->hasFile('bukti3')) {
|
||||
$filePaths['bukti3'] = Storage::disk('nextcloud')->putFileAs($folderPath, $request->file('bukti3'), $request->file('bukti3')->getClientOriginalName());
|
||||
$bukti3 = $request->file('bukti3');
|
||||
$filename = Str::uuid() . '.' . $bukti3->extension();
|
||||
|
||||
$filePaths['bukti3'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti3->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
|
||||
// Save the form data
|
||||
|
||||
Reference in New Issue
Block a user