You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.7 KiB
83 lines
2.7 KiB
<?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); |
|
// }
|
|
|