Siopas Inventory PETI for ISTW Website
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.

91 lines
3.0 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:id,name,code_customer,lot_no,nip,no_hp,tgl_lahir,jenis_kelamin,agama,address',
'peti.tipe_peti:id,type,size_peti,description',
'warehouse',
'warehouseEnter'
])
->where('updated_by', '=', null)
->get();
return ResponseFormatter::success([
'message' => 'Data peminjaman 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);
// }