From edca8ee8351708892456a1010972da867ee9ce0d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Nov 2023 14:30:33 +0700 Subject: [PATCH] Update API Disposal dan TransferApi --- .../v1/DisposalApi/DisposalApiController.php | 21 +++++++ .../PeminjamanApi/PeminjamanApiController.php | 4 ++ .../v1/TransferApi/TransferApiController.php | 60 +++++++++++++++++++ routes/api.php | 2 + 4 files changed, 87 insertions(+) create mode 100644 app/Http/Controllers/API/v1/DisposalApi/DisposalApiController.php create mode 100644 app/Http/Controllers/API/v1/TransferApi/TransferApiController.php diff --git a/app/Http/Controllers/API/v1/DisposalApi/DisposalApiController.php b/app/Http/Controllers/API/v1/DisposalApi/DisposalApiController.php new file mode 100644 index 0000000..62a9498 --- /dev/null +++ b/app/Http/Controllers/API/v1/DisposalApi/DisposalApiController.php @@ -0,0 +1,21 @@ + true, + 'message' => 'Data Disposal Peti berhasil diambil', + 'disposals' => $disposals + ], 200); + } +} diff --git a/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php b/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php index b6e967c..b7de3cc 100644 --- a/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php +++ b/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php @@ -58,6 +58,8 @@ class PeminjamanApiController extends Controller { $mobile_id = $request->input('mobile_id'); $peti_id = $request->input('peti_id'); + $customer_id = $request->input('customer_id'); + $warehouse_id = $request->input('warehouse_id'); $exit_at = $request->input('exit_at'); $exit_pic = $request->input('exit_pic'); $exit_warehouse = $request->input('exit_warehouse'); @@ -87,6 +89,8 @@ class PeminjamanApiController extends Controller $newRecord = new asset_status; $newRecord->mobile_id = $mobile_id; $newRecord->peti_id = $peti_id; + $newRecord->customer_id = $customer_id; + $newRecord->warehouse_id = $warehouse_id; $newRecord->exit_at = $exit_at; $newRecord->exit_pic = $exit_pic; $newRecord->exit_warehouse = $exit_warehouse; diff --git a/app/Http/Controllers/API/v1/TransferApi/TransferApiController.php b/app/Http/Controllers/API/v1/TransferApi/TransferApiController.php new file mode 100644 index 0000000..c31d5ef --- /dev/null +++ b/app/Http/Controllers/API/v1/TransferApi/TransferApiController.php @@ -0,0 +1,60 @@ + true, + 'message' => 'Data Transfer Peti berhasil diambil', + 'transfer_peti' => $transfer + ]); + } + + public function store(Request $request) + { + $mobile_id = $request->input('mobile_id'); + $peti_id = $request->input('peti_id'); + $name_customer = $request->input('name_customer'); + $source_warehouse = $request->input('source_warehouse'); + $destination_warehouse = $request->input('destination_warehouse'); + $transfer_date = $request->input('date'); + $created_by = $request->input('created_by'); + $created_at = $request->input('created_at'); + + $transfer = Transfer::create([ + 'mobile_id' => $mobile_id, + 'peti_id' => $peti_id, + 'name_customer' => $name_customer, + 'source_warehouse' => $source_warehouse, + 'destination_warehouse' => $destination_warehouse, + 'date' => $transfer_date, + 'created_by' => $created_by, + 'created_at' => $created_at + ]); + + if ($transfer) { + return ResponseFormatter::success([ + 'status' => true, + 'message' => 'Data Transfer Peti berhasil ditambahkan', + 'transfer_peti' => $transfer + ]); + } else { + return ResponseFormatter::error([ + 'status' => false, + 'message' => 'Data Transfer Peti gagal ditambahkan', + 'transfer_peti' => $transfer + ]); + } + } +} diff --git a/routes/api.php b/routes/api.php index 6005f77..fc25058 100644 --- a/routes/api.php +++ b/routes/api.php @@ -50,6 +50,8 @@ Route::prefix('v1')->group(function () { Route::get('/m-transfer-peti', [App\Http\Controllers\API\v1\TransferApi\TransferApiController::class, 'index'])->name('transfer-peti'); Route::post('/m-transfer-peti/store', [App\Http\Controllers\API\v1\TransferApi\TransferApiController::class, 'store'])->name('transfer-peti.store'); + + Route::get('/m-disposal-peti', [App\Http\Controllers\API\v1\DisposalApi\DisposalApiController::class, 'index'])->name('disposal-peti'); }); Route::middleware('auth:sanctum')->get('/user', function (Request $request) {