|
|
@ -64,22 +64,44 @@ class TransferController extends Controller |
|
|
|
$validatedData['updated_by'] = $currentUser->fullname; |
|
|
|
$validatedData['updated_by'] = $currentUser->fullname; |
|
|
|
|
|
|
|
|
|
|
|
// Membuat entitas Transfer |
|
|
|
// Membuat entitas Transfer |
|
|
|
$transfer = Transfer::create($validatedData); |
|
|
|
Transfer::create($validatedData); |
|
|
|
// dd($transfer); |
|
|
|
|
|
|
|
// Mengupdate warehouse_id pada model Peti |
|
|
|
|
|
|
|
Peti::where('id', $transfer->peti_id) |
|
|
|
|
|
|
|
->update([ |
|
|
|
|
|
|
|
'warehouse_id' => $transfer->destination_warehouse, |
|
|
|
|
|
|
|
'customer_id' => $transfer->name_customer, // tambahan update customer id |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return redirect()->route('dashboard.transfer.index')->with('success', 'Data Transfer Peti berhasil ditambahkan'); |
|
|
|
return redirect()->route('dashboard.transfer.index')->with('success', 'Data Transfer Peti berhasil ditambahkan'); |
|
|
|
} catch (\Throwable $th) { |
|
|
|
} catch (\Throwable $th) { |
|
|
|
return redirect()->back()->with('error', 'Data Transfer Peti gagal ditransfer'); |
|
|
|
return redirect()->back()->with('error', 'Data Transfer Peti gagal ditransfer'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//proses tambah data transfer beserta update data peti |
|
|
|
|
|
|
|
// public function store(ValidasiCreateTransfer $request) |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// // dd($request); |
|
|
|
|
|
|
|
// try { |
|
|
|
|
|
|
|
// // Mendapatkan informasi pengguna yang sedang login |
|
|
|
|
|
|
|
// $currentUser = Auth::user(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Validasi data dari request |
|
|
|
|
|
|
|
// $validatedData = $request->validated(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Menambahkan informasi pengguna ke dalam data yang akan disimpan |
|
|
|
|
|
|
|
// $validatedData['mobile_id'] = Uuid::v4(); // Menambahkan ID Mobile |
|
|
|
|
|
|
|
// $validatedData['created_by'] = $currentUser->fullname; |
|
|
|
|
|
|
|
// $validatedData['updated_by'] = $currentUser->fullname; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Membuat entitas Transfer |
|
|
|
|
|
|
|
// $transfer = Transfer::create($validatedData); |
|
|
|
|
|
|
|
// // dd($transfer); |
|
|
|
|
|
|
|
// // Mengupdate warehouse_id pada model Peti |
|
|
|
|
|
|
|
// Peti::where('id', $transfer->peti_id) |
|
|
|
|
|
|
|
// ->update([ |
|
|
|
|
|
|
|
// 'warehouse_id' => $transfer->destination_warehouse, |
|
|
|
|
|
|
|
// 'customer_id' => $transfer->name_customer, // tambahan update customer id |
|
|
|
|
|
|
|
// ]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return redirect()->route('dashboard.transfer.index')->with('success', 'Data Transfer Peti berhasil ditambahkan'); |
|
|
|
|
|
|
|
// } catch (\Throwable $th) { |
|
|
|
|
|
|
|
// return redirect()->back()->with('error', 'Data Transfer Peti gagal ditransfer'); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Display the specified resource. |
|
|
|
* Display the specified resource. |
|
|
@ -112,7 +134,7 @@ class TransferController extends Controller |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function update(ValidasiUpdateTransfer $request, $id) |
|
|
|
public function update(ValidasiUpdateTransfer $request, $id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// dd("oke"); |
|
|
|
// dd($request->all()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
// Mendapatkan informasi pengguna yang sedang login |
|
|
|
// Mendapatkan informasi pengguna yang sedang login |
|
|
|
$currentUser = Auth::user(); |
|
|
|
$currentUser = Auth::user(); |
|
|
@ -133,18 +155,46 @@ class TransferController extends Controller |
|
|
|
// Memperbarui data transfer |
|
|
|
// Memperbarui data transfer |
|
|
|
$transfer->update($validatedData); |
|
|
|
$transfer->update($validatedData); |
|
|
|
|
|
|
|
|
|
|
|
// Mengupdate warehouse_id pada model Peti |
|
|
|
|
|
|
|
Peti::where('id', $transfer->peti_id) |
|
|
|
|
|
|
|
->update([ |
|
|
|
|
|
|
|
'warehouse_id' => $transfer->destination_warehouse, |
|
|
|
|
|
|
|
'customer_id' => $transfer->name_customer, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return redirect()->route('dashboard.transfer.index')->with('success', 'Data Transfer Peti berhasil diperbaharui'); |
|
|
|
return redirect()->route('dashboard.transfer.index')->with('success', 'Data Transfer Peti berhasil diperbaharui'); |
|
|
|
} catch (\Throwable $th) { |
|
|
|
} catch (\Throwable $th) { |
|
|
|
return redirect()->back()->with('error', 'Data Transfer Peti gagal diperbaharui'); |
|
|
|
return redirect()->back()->with('error', 'Data Transfer Peti gagal diperbaharui'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//proses tambah data transfer beserta update data peti |
|
|
|
|
|
|
|
// public function update(ValidasiUpdateTransfer $request, $id) |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// try { |
|
|
|
|
|
|
|
// // Mendapatkan informasi pengguna yang sedang login |
|
|
|
|
|
|
|
// $currentUser = Auth::user(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Validasi data dari request |
|
|
|
|
|
|
|
// $validatedData = $request->validated(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Menambahkan informasi pengguna ke dalam data yang akan disimpan |
|
|
|
|
|
|
|
// $validatedData['updated_by'] = $currentUser->fullname; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Mencari transfer berdasarkan ID |
|
|
|
|
|
|
|
// $transfer = Transfer::find($id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!$transfer) { |
|
|
|
|
|
|
|
// return redirect()->route('dashboard.transfer.index')->with('error', 'Data Transfer Peti tidak ditemukan'); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Memperbarui data transfer |
|
|
|
|
|
|
|
// $transfer->update($validatedData); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Mengupdate warehouse_id pada model Peti |
|
|
|
|
|
|
|
// Peti::where('id', $transfer->peti_id) |
|
|
|
|
|
|
|
// ->update([ |
|
|
|
|
|
|
|
// 'warehouse_id' => $transfer->destination_warehouse, |
|
|
|
|
|
|
|
// 'customer_id' => $transfer->name_customer, |
|
|
|
|
|
|
|
// ]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return redirect()->route('dashboard.transfer.index')->with('success', 'Data Transfer Peti berhasil diperbaharui'); |
|
|
|
|
|
|
|
// } catch (\Throwable $th) { |
|
|
|
|
|
|
|
// return redirect()->back()->with('error', 'Data Transfer Peti gagal diperbaharui'); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Remove the specified resource from storage. |
|
|
|
* Remove the specified resource from storage. |
|
|
|