59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Validator;
|
|
use App\Models\Pengguna;
|
|
use App\Models\JenisBarang;
|
|
use App\Http\Resources\BarangResource;
|
|
|
|
class PenggunaController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$data = Pengguna::all();
|
|
return response()->json(['data'=>BarangResource::collection($data), 'msg'=>'List all data pengguna ']);
|
|
}
|
|
public function show($id)
|
|
{
|
|
|
|
$data = Pengguna::where('id',$id)->get();
|
|
|
|
// dd($data);
|
|
return response()->json(['data'=>BarangResource::collection($data), 'msg'=>'Detail Pengguna ']);
|
|
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
|
|
$data = Pengguna::where('id',$id)->delete();
|
|
if($data){
|
|
return response()->json(['data'=>'', 'msg'=>'Data Pengguna Berhasil di hapus ']);
|
|
|
|
}else{
|
|
|
|
return response()->json(['data'=>'', 'msg'=>'Data Pengguna Gagal di hapus ']);
|
|
}
|
|
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public function jenis_barang()
|
|
{
|
|
$data = JenisBarang::all();
|
|
|
|
return response()->json(['data'=>BarangResource::collection($data), 'msg'=>'List Data Jenis Barang']);
|
|
|
|
|
|
}
|
|
|
|
}
|