From d9b48c78d5a53d814d91f90521ecd5d8f0f28dea Mon Sep 17 00:00:00 2001 From: Gunawan19621 Date: Fri, 24 Nov 2023 11:06:57 +0700 Subject: [PATCH] update transfer jangan merubah data peti --- app/Http/Controllers/DisposalController.php | 3 +- app/Http/Controllers/TransferController.php | 86 +++++++++++++++---- .../views/dashboard/Transfer/edit.blade.php | 11 ++- 3 files changed, 79 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/DisposalController.php b/app/Http/Controllers/DisposalController.php index 6915ba1..8f8d170 100644 --- a/app/Http/Controllers/DisposalController.php +++ b/app/Http/Controllers/DisposalController.php @@ -17,7 +17,8 @@ class DisposalController extends Controller public function index() { $data = [ - 'disposal' => Disposal::orderBy('created_at', 'desc')->get(), + 'disposal' => Disposal::where('status_disposal', 'INAKTIF')->orderBy('created_at', 'desc')->get(), + // 'disposal' => Disposal::orderBy('created_at', 'desc')->get(), 'active' => 'menu-disposal', ]; return view('dashboard.Disposal.index', $data); diff --git a/app/Http/Controllers/TransferController.php b/app/Http/Controllers/TransferController.php index cf92d61..0cf2fe6 100644 --- a/app/Http/Controllers/TransferController.php +++ b/app/Http/Controllers/TransferController.php @@ -64,22 +64,44 @@ class TransferController extends Controller $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 - ]); + Transfer::create($validatedData); 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'); } } - - + //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. @@ -112,7 +134,7 @@ class TransferController extends Controller */ public function update(ValidasiUpdateTransfer $request, $id) { - // dd("oke"); + // dd($request->all()); try { // Mendapatkan informasi pengguna yang sedang login $currentUser = Auth::user(); @@ -133,18 +155,46 @@ class TransferController extends Controller // 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'); } } + //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. diff --git a/resources/views/dashboard/Transfer/edit.blade.php b/resources/views/dashboard/Transfer/edit.blade.php index 2b0d0f1..30f868d 100644 --- a/resources/views/dashboard/Transfer/edit.blade.php +++ b/resources/views/dashboard/Transfer/edit.blade.php @@ -17,7 +17,14 @@
- + + + + + + {{-- + --}}