Browse Source

Update: Api peminjaman dan pengembalian, model

master
unknown 1 year ago
parent
commit
429c3d9540
  1. 6
      app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php
  2. 23
      app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php
  3. 13
      app/Http/Controllers/API/v1/PengembalianApi/PengembalianBarangApiController.php
  4. 1
      app/Http/Controllers/PeminjamanController.php
  5. 6
      app/Models/Peti.php
  6. 14
      app/Models/asset_status.php
  7. 3
      resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/edit.blade.php
  8. 4
      routes/api.php

6
app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php

@ -10,7 +10,11 @@ class AssetStatusApiController extends Controller
{ {
public function index() 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([ return ResponseFormatter::success([
'message' => 'Data asset berhasil diambil', 'message' => 'Data asset berhasil diambil',
'asset' => $m_asset, 'asset' => $m_asset,

23
app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php

@ -12,7 +12,12 @@ class PeminjamanApiController extends Controller
{ {
public function index() 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([ return ResponseFormatter::success([
'message' => 'Data peminjaman berhasil diambil', '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() public function getWarehouseEnter()
{ {
$warehouse = \App\Models\m_warehouse::get(); $warehouse = \App\Models\m_warehouse::get();

13
app/Http/Controllers/API/v1/PengembalianApi/PengembalianBarangApiController.php

@ -10,11 +10,18 @@ class PengembalianBarangApiController extends Controller
{ {
public function index() 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([ return ResponseFormatter::success([
'message' => 'Data pengembalian berhasil diambil', 'message' => 'Data peminjaman berhasil diambil',
'asset_status' => $pengembalian 'asset_status' => $pengembalian,
]); ]);
} }

1
app/Http/Controllers/PeminjamanController.php

@ -20,6 +20,7 @@ class PeminjamanController extends Controller
$data = [ $data = [
'asset' => m_asset::all(), 'asset' => m_asset::all(),
// 'peminjaman' => asset_status::get(),
'peminjaman' => asset_status::get(), 'peminjaman' => asset_status::get(),
'warehouse' => m_warehouse::get(), 'warehouse' => m_warehouse::get(),
'active' => 'menu-peminjaman', 'active' => 'menu-peminjaman',

6
app/Models/Peti.php

@ -27,14 +27,14 @@ class Peti extends Model
public function customer() 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() 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() 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');
} }
} }

14
app/Models/asset_status.php

@ -34,26 +34,32 @@ class asset_status extends Model
public function warehouse() 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() 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() 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() 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() public function customer()
{ {
return $this->belongsTo(Customer::class, 'customer_id'); return $this->belongsTo(Customer::class, 'customer_id');
} }
// public function customer()
// {
// return $this->belongsTo(Customer::class, 'customer_id')->select('id', 'name');
// }
} }

3
resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/edit.blade.php

@ -20,7 +20,8 @@
<option value="{{ $data_type->id }}" <option value="{{ $data_type->id }}"
@if ($data_type->id == $peti->tipe_peti_id) selected @if ($data_type->id == $peti->tipe_peti_id) selected
@else @endif> @else @endif>
{{ $data_type->type }}</option> {{ $data_type->type }}
</option>
@endforeach @endforeach
</select> </select>

4
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::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::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::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'); Route::get('/peti-asset', [App\Http\Controllers\API\v1\AssetStatusApi\AssetStatusApiController::class, 'index'])->name('peti.barang');

Loading…
Cancel
Save