Gunawan19621
1 year ago
5 changed files with 114 additions and 15 deletions
@ -0,0 +1,83 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers\API\v1\PengembalianApi; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use App\Helpers\ResponseFormatter; |
||||
use App\Http\Controllers\Controller; |
||||
|
||||
class PengembalianBarangApiController extends Controller |
||||
{ |
||||
public function index() |
||||
{ |
||||
$pengembalian = \App\Models\asset_status::with(['peti.customer', 'peti.tipe_peti', 'warehouse'])->get(); |
||||
|
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data pengembalian berhasil diambil', |
||||
'asset_status' => $pengembalian |
||||
]); |
||||
} |
||||
|
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
|
||||
$pengembalian = \App\Models\asset_status::find($id); |
||||
|
||||
if (!$pengembalian) { |
||||
return ResponseFormatter::error([ |
||||
'message' => 'Data pengembalian tidak ditemukan', |
||||
], 'Data Not Found', 404); |
||||
} |
||||
|
||||
$pengembalian->update([ |
||||
'enter_at' => $request->enter_at, |
||||
'enter_pic' => $request->enter_pic, |
||||
'enter_warehouse' => $request->enter_warehouse, |
||||
'kondisi_peti' => $request->kondisi_peti, |
||||
'updated_by' => $request->updated_by, |
||||
]); |
||||
|
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data pengembalian berhasil diupdate', |
||||
'asset_status' => $pengembalian |
||||
]); |
||||
} |
||||
} |
||||
|
||||
|
||||
// try { |
||||
// // $this->validate($request, [ |
||||
// // 'enter_at' => 'required', |
||||
// // 'enter_pic' => 'required', |
||||
// // 'enter_warehouse' => 'required', |
||||
// // 'kondisi_peti' => 'required', |
||||
// // 'updated_by' => 'required', |
||||
// // ]); |
||||
|
||||
// $pengembalian = \App\Models\asset_status::find($id); |
||||
|
||||
// if (!$pengembalian) { |
||||
// return ResponseFormatter::error([ |
||||
// 'message' => 'Data pengembalian tidak ditemukan', |
||||
// ], 'Data Not Found', 404); |
||||
// } |
||||
|
||||
// $pengembalian->update([ |
||||
// 'enter_at' => $request->enter_at, |
||||
// 'enter_pic' => $request->enter_pic, |
||||
// 'enter_warehouse' => $request->enter_warehouse, |
||||
// 'kondisi_peti' => $request->kondisi_peti, |
||||
// 'updated_by' => $request->updated_by, |
||||
// ]); |
||||
|
||||
// return ResponseFormatter::success([ |
||||
// 'message' => 'Data pengembalian berhasil diupdate', |
||||
// 'asset_status' => $pengembalian |
||||
// ]); |
||||
// } catch (\Exception $e) { |
||||
// return ResponseFormatter::error([ |
||||
// 'message' => 'Terjadi kesalahan dalam memperbarui data pengembalian', |
||||
// 'error' => $e->getMessage(), |
||||
// ], 'Update Failed', 500); |
||||
// } |
Loading…
Reference in new issue