join('tbl_jenis_barang','tbl_jenis_barang.id','=','tbl_barang.jenis_barang_id') ->get(['tbl_barang.*','tbl_satuan.nama_satuan','tbl_jenis_barang.nama_jenis']); return response()->json(['data'=>BarangResource::collection($data), 'msg'=>'List All data barang']); } public function show($id) { $data = Barang::where('id',$id)->get(); foreach($data as $i){ $nama_barang = $i->nama_barang; } // dd($data); return response()->json(['data'=>BarangResource::collection($data), 'msg'=>'Detail Barang '.$nama_barang]); } public function detail_barang(Request $request) { // dd($request->all()); $id_barang = $request->id_barang; $data = Barang::where('id',$id_barang)->get(); foreach($data as $i){ $nama_barang = $i->nama_barang; } // dd($data); return response()->json(['data'=>BarangResource::collection($data), 'msg'=>'Detail Barang '.$nama_barang]); } public function destroy($id) { $data = Barang::where('id',$id)->delete(); if($data){ return response()->json(['data'=>'', 'msg'=>'Data Barang Berhasil di hapus ']); }else{ return response()->json(['data'=>'', 'msg'=>'Data Barang 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']); } }