From 429c3d9540dad55faaa26e762fb052bf17bcd5dc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Nov 2023 21:08:54 +0700 Subject: [PATCH] Update: Api peminjaman dan pengembalian, model --- .../AssetStatusApiController.php | 6 ++++- .../PeminjamanApi/PeminjamanApiController.php | 23 ++++++++++++++++++- .../PengembalianBarangApiController.php | 13 ++++++++--- app/Http/Controllers/PeminjamanController.php | 1 + app/Models/Peti.php | 6 ++--- app/Models/asset_status.php | 14 +++++++---- .../Manajemen_Peti/Peti/edit.blade.php | 3 ++- routes/api.php | 4 +++- 8 files changed, 56 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php b/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php index 0df022b..291e9ee 100644 --- a/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php +++ b/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php @@ -10,7 +10,11 @@ class AssetStatusApiController extends Controller { public function index() { - $m_asset = \App\Models\Peti::with(['warehouse', 'tipe_peti', 'customer'])->get(); + $m_asset = \App\Models\Peti::with([ + 'warehouse', + 'tipe_peti', + 'customer' + ])->get(); return ResponseFormatter::success([ 'message' => 'Data asset berhasil diambil', 'asset' => $m_asset, diff --git a/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php b/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php index 3bf3244..628d17a 100644 --- a/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php +++ b/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php @@ -12,7 +12,12 @@ class PeminjamanApiController extends Controller { public function index() { - $peminjaman = \App\Models\asset_status::with(['peti.customer', 'peti.tipe_peti', 'warehouse', 'warehouseEnter'])->get(); + $peminjaman = \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' + ])->get(); return ResponseFormatter::success([ 'message' => 'Data peminjaman berhasil diambil', @@ -20,6 +25,22 @@ class PeminjamanApiController extends Controller ]); } + // public function index() + // { + // $peminjaman = \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' + // ])->paginate(10); + + // return ResponseFormatter::success([ + // 'message' => 'Data peminjaman berhasil diambil', + // 'asset_status' => $peminjaman, + // ]); + // } + + public function getWarehouseEnter() { $warehouse = \App\Models\m_warehouse::get(); diff --git a/app/Http/Controllers/API/v1/PengembalianApi/PengembalianBarangApiController.php b/app/Http/Controllers/API/v1/PengembalianApi/PengembalianBarangApiController.php index afb8d64..c72f4b4 100644 --- a/app/Http/Controllers/API/v1/PengembalianApi/PengembalianBarangApiController.php +++ b/app/Http/Controllers/API/v1/PengembalianApi/PengembalianBarangApiController.php @@ -10,11 +10,18 @@ class PengembalianBarangApiController extends Controller { public function index() { - $pengembalian = \App\Models\asset_status::with(['peti.customer', 'peti.tipe_peti', 'warehouse'])->get(); + $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 pengembalian berhasil diambil', - 'asset_status' => $pengembalian + 'message' => 'Data peminjaman berhasil diambil', + 'asset_status' => $pengembalian, ]); } diff --git a/app/Http/Controllers/PeminjamanController.php b/app/Http/Controllers/PeminjamanController.php index 1b3fd08..6bbb73b 100644 --- a/app/Http/Controllers/PeminjamanController.php +++ b/app/Http/Controllers/PeminjamanController.php @@ -20,6 +20,7 @@ class PeminjamanController extends Controller $data = [ 'asset' => m_asset::all(), + // 'peminjaman' => asset_status::get(), 'peminjaman' => asset_status::get(), 'warehouse' => m_warehouse::get(), 'active' => 'menu-peminjaman', diff --git a/app/Models/Peti.php b/app/Models/Peti.php index 8631a70..599dd50 100644 --- a/app/Models/Peti.php +++ b/app/Models/Peti.php @@ -27,14 +27,14 @@ class Peti extends Model public function customer() { - return $this->belongsTo(Customer::class, 'customer_id'); + return $this->belongsTo(Customer::class, 'customer_id')->select('id', 'name', 'code_customer', 'lot_no', 'nip', 'no_hp', 'tgl_lahir', 'jenis_kelamin', 'agama', 'address'); } public function warehouse() { - return $this->belongsTo(m_warehouse::class, 'warehouse_id'); + return $this->belongsTo(m_warehouse::class, 'warehouse_id')->select('id', 'name', 'address'); } public function tipe_peti() { - return $this->belongsTo(Type_peti::class, 'tipe_peti_id'); + return $this->belongsTo(Type_peti::class, 'tipe_peti_id')->select('id', 'type', 'size_peti', 'description'); } } diff --git a/app/Models/asset_status.php b/app/Models/asset_status.php index 708092c..daab5d1 100644 --- a/app/Models/asset_status.php +++ b/app/Models/asset_status.php @@ -34,26 +34,32 @@ class asset_status extends Model public function warehouse() { - return $this->belongsTo(m_warehouse::class, 'exit_warehouse'); + return $this->belongsTo(m_warehouse::class, 'exit_warehouse')->select('id', 'name', 'address'); } public function warehouseEnter() { - return $this->belongsTo(m_warehouse::class, 'enter_warehouse'); + return $this->belongsTo(m_warehouse::class, 'enter_warehouse')->select('id', 'name', 'address'); } public function peti() { - return $this->belongsTo(Peti::class, 'peti_id'); + return $this->belongsTo(Peti::class, 'peti_id')->select('id', 'tipe_peti_id', 'warna', 'fix_lot', 'packing_no', 'customer_id', 'jumlah', 'date_pembuatan', 'warehouse_id', 'status_disposal'); } public function tipe_peti() { - return $this->belongsTo(Type_peti::class, 'type'); + return $this->belongsTo(Type_peti::class, 'type')->select('id', 'type', 'size_peti', 'description'); } public function customer() { return $this->belongsTo(Customer::class, 'customer_id'); } + + // public function customer() + // { + // return $this->belongsTo(Customer::class, 'customer_id')->select('id', 'name'); + // } + } diff --git a/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/edit.blade.php b/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/edit.blade.php index f957ff5..928210b 100644 --- a/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/edit.blade.php +++ b/resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/edit.blade.php @@ -20,7 +20,8 @@ + {{ $data_type->type }} + @endforeach diff --git a/routes/api.php b/routes/api.php index 0b1004c..8cfaf6f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -28,7 +28,9 @@ Route::prefix('v1')->group(function () { Route::get('/asset-status', [App\Http\Controllers\API\v1\PeminjamanApi\PeminjamanApiController::class, 'index'])->name('peminjaman-barang'); Route::post('/asset-status/store', [App\Http\Controllers\API\v1\PeminjamanApi\PeminjamanApiController::class, 'store'])->name('peminjaman-barang.store'); Route::get('/asset-status/show/{id}', [App\Http\Controllers\API\v1\PeminjamanApi\PeminjamanApiController::class, 'show'])->name('peminjaman-barang.show'); - Route::put('/asset-status/update/{id}', [App\Http\Controllers\API\v1\PengembalianApi\PengembalianBarangApiController::class, 'update'])->name('peminjaman-barang.update'); + + Route::get('/asset-status/pengembalian', [App\Http\Controllers\API\v1\PengembalianApi\PengembalianBarangApiController::class, 'index'])->name('pengembalian-barang'); + Route::put('/asset-status/update/{id}', [App\Http\Controllers\API\v1\PengembalianApi\PengembalianBarangApiController::class, 'update'])->name('pengembalian-barang.update'); Route::get('/peti-asset', [App\Http\Controllers\API\v1\AssetStatusApi\AssetStatusApiController::class, 'index'])->name('peti.barang');