orderBy('name', 'ASC')->get(); foreach ($hewan as $item) { $item->foto = url('images/foto/' . $item->foto); } return response()->json([ 'success' => true, 'message' => 'List data hewan', 'data' => $hewan ]); } public function searchHewan(Request $request) { $keyword = $request->keyword; $hewan = Hewan::with('kategori') ->where('name', 'LIKE', "$keyword%") ->get(); foreach ($hewan as $item) { $item->foto = url('images/foto/' . $item->foto); } return response()->json([ 'success' => true, 'message' => 'Hasil pencarian hewan', 'data' => $hewan ]); } public function getHewanById($id) { $hewan = Hewan::with('kategori')->find($id); if (!$hewan) { return response()->json([ 'success' => false, 'message' => 'Data hewan tidak ditemukan', 'data' => null ]); } $hewan->foto = url('images/foto/' . $hewan->foto); return response()->json([ 'success' => true, 'message' => 'Detail data hewan', 'data' => $hewan ]); } }