unknown
1 year ago
6 changed files with 124 additions and 41 deletions
@ -1,23 +0,0 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers\API\v1\AssetStatusApi; |
||||
|
||||
use App\Helpers\ResponseFormatter; |
||||
use App\Http\Controllers\Controller; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AssetStatusApiController extends Controller |
||||
{ |
||||
public function index() |
||||
{ |
||||
$m_asset = \App\Models\Peti::with([ |
||||
'warehouse', |
||||
'tipe_peti', |
||||
'customer' |
||||
])->get(); |
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data asset berhasil diambil', |
||||
'asset' => $m_asset, |
||||
], 200); |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers\API\v1\PetiApi; |
||||
|
||||
use App\Helpers\ResponseFormatter; |
||||
use App\Http\Controllers\Controller; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class PetiApiController extends Controller |
||||
{ |
||||
public function index() |
||||
{ |
||||
$petis = \App\Models\Peti::with([ |
||||
'customer:id,name,code_customer,lot_no,nip,no_hp,tgl_lahir,jenis_kelamin,agama,address', |
||||
'tipe_peti:id,type,size_peti,description', |
||||
'warehouse:id,name,address', |
||||
])->get(); |
||||
|
||||
if (!$petis) { |
||||
return ResponseFormatter::error([ |
||||
'message' => 'Data peti tidak ditemukan', |
||||
], 'Data Not Found', 404); |
||||
} |
||||
|
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data peti berhasil diambil', |
||||
'petis' => $petis, |
||||
], 200); |
||||
} |
||||
|
||||
public function show($id) |
||||
{ |
||||
$peti = \App\Models\Peti::with([ |
||||
'customer:id,name,code_customer,lot_no,nip,no_hp,tgl_lahir,jenis_kelamin,agama,address', |
||||
'tipe_peti:id,type,size_peti,description', |
||||
'warehouse:id,name,address', |
||||
])->find($id); |
||||
|
||||
if (!$peti) { |
||||
return ResponseFormatter::error([ |
||||
'message' => 'Data peti tidak ditemukan', |
||||
], 'Data Not Found', 404); |
||||
} |
||||
|
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data peti berhasil diambil', |
||||
'peti' => $peti, |
||||
], 200); |
||||
} |
||||
|
||||
public function edit($id) |
||||
{ |
||||
$peti = \App\Models\Peti::with([ |
||||
'customer:id,name,code_customer,lot_no,nip,no_hp,tgl_lahir,jenis_kelamin,agama,address', |
||||
'tipe_peti:id,type,size_peti,description', |
||||
'warehouse:id,name,address', |
||||
])->find($id); |
||||
|
||||
if (!$peti) { |
||||
return ResponseFormatter::error([ |
||||
'message' => 'Data peti tidak ditemukan', |
||||
], 'Data Not Found', 404); |
||||
} |
||||
|
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data peti berhasil diambil', |
||||
'petis' => $peti, |
||||
], 200); |
||||
} |
||||
|
||||
public function update(Request $request, $id) |
||||
{ |
||||
$peti = \App\Models\Peti::find($id); |
||||
|
||||
if (!$peti) { |
||||
return ResponseFormatter::error([ |
||||
'message' => 'Data peti tidak ditemukan', |
||||
], 'Data Not Found', 404); |
||||
} |
||||
|
||||
// $peti->update($request->all()); |
||||
|
||||
$peti->update([ |
||||
'warehouse_id' => $request->warehouse_id, |
||||
'updated_by' => $request->updated_by, |
||||
]); |
||||
|
||||
return ResponseFormatter::success([ |
||||
'message' => 'Data peti berhasil diupdate', |
||||
'petis' => $peti, |
||||
], 200); |
||||
} |
||||
} |
Loading…
Reference in new issue