Postingan lainnya
Pagination gagal saat memanggil link()
Saya ada API dengan balikan begini
{
"response_code": "00",
"desc": "success",
"list_campus": {
"current_page": 1,
"data": [
{
"campus_id": "sdmfn",
"campus_slug": "Universitas-Hasanuddin",
"campus_name": "Universitas Hasanuddin",
"campus_alias": "kadk",
"campus_email": "kd@as.s",
"campus_telp": "(024) 7465403",
"campus_fax": "adk",
"campus_desc": "smdfn",
"campus_address": "kav",
"campus_accred": "A",
"campus_accred_number": null,
"campus_province": "Sulawesi Selatan",
"campus_city": "Makassar",
"campus_country": "adk",
"campus_type": "pts",
"campus_image": "http://localhost:9000/univ_image/unhas.jpg",
"campus_link": "knvak",
"campus_facilities": null,
"campus_logo": "http://localhost:9000/logo_univ/unhas.jpg",
"created_date": "2019-05-19 16:55:50",
"modify_date": null,
"create_by": null
},
{
"campus_id": "sdlfdsl",
"campus_slug": "Universitas-Semarang",
"campus_name": "Universitas Semarang",
"campus_alias": "aksdask",
"campus_email": "sdklfdl@ff.com",
"campus_telp": "(024) 7465403",
"campus_fax": "121121212",
"campus_desc": "djf sdfjksd sdjkf ",
"campus_address": "skadf sdklsda sda asdjasdn",
"campus_accred": "A",
"campus_accred_number": null,
"campus_province": "Jawa Tengah",
"campus_city": "Semarang",
"campus_country": "Indonesia",
"campus_type": "pts",
"campus_image": "http://localhost:9000/univ_image/undip.jpg",
"campus_link": "askdasd",
"campus_facilities": null,
"campus_logo": "http://localhost:9000/logo_univ/logo.jpg",
"created_date": "2019-05-16 03:00:08",
"modify_date": null,
"create_by": null
}
],
"first_page_url": "http://localhost/api_ios/public/ios/campus/filter/pts?page=1",
"from": 1,
"last_page": 3,
"last_page_url": "http://localhost/api_ios/public/ios/campus/filter/pts?page=3",
"next_page_url": "http://localhost/api_ios/public/ios/campus/filter/pts?page=2",
"path": "http://localhost/api_ios/public/ios/campus/filter/pts",
"per_page": 2,
"prev_page_url": null,
"to": 2,
"total": 5
}
}
saya mengaksesnya dengan frontend dengan cara controller
public function filter_by_type_kampus(Request $request)
{
$type_kampus = $request->type_kampus;
if ($type_kampus == '') {
return $this->index();
}
$client = new client();
$request = $client->get('http://localhost:9000/ios/campus/filter/'.$type_kampus);
$response = $request->getBody()->getContents();
$filter_kampus = json_decode($response, TRUE);
if ($filter_kampus['response_code'] != '00') {
return view('error-page-campus');
}else{
return view('campus_filter',compact('filter_kampus'));
}
}
dan di view seperti ini view
@php
$loop = $filter_kampus['list_campus']['data'];
@endphp
@foreach ($loop as $kampus)
<div class="col-lg-4 col-md-4 col-sm-12 mb-4">
<div class="list-grid-layout modern-layout">
<div class="grid-layout-header">
<a href="listing-detail.html" class="list-thumb">
<img src="{{ $kampus['campus_image'] }}" class="img-fluid mx-auto" alt="">
</a>
</div>
<div class="grid-layout-body">
<div class="gl-list-author">
<a data-toggle="tooltip" data-original-title="{{ $kampus['campus_name'] }}" href="author-detail.html">
<img src="{{ $kampus['campus_logo'] }}" alt="{{ $kampus['campus_name'] }}">
<span class="verified-badge"><i class="fa fa-check"></i></span>
</a>
</div>
<div class="gl-list-caption">
<h4><a href="listing-detail.html" class="list-title">{{ $kampus['campus_name'] }}</a></h4>
</div>
<div class="grid-layout-info">
<ul>
<li><i class="ti-headphone"></i> {{ $kampus['campus_telp'] }}</li>
<li><i class="ti-location-pin"></i>{{ $kampus['campus_city'] }}, {{ $kampus['campus_province'] }}</li>
</ul>
</div>
</div>
<div class="grid-layout-footer">
<a href="category-list.html">
<div class="cat-icon-box rounded-circle cbg-1">
{{ $kampus['campus_accred'] }}
</div>
<div class="icon-box-text">
@if($kampus['campus_type'] == 'pts')
SWASTA
@else
NEGERI
@endif
</div>
</a>
<div class="ft-loke">
<a href="#"><i class="ti-heart"></i></a>
</div>
</div>
</div>
</div>
@endforeach
<div class="col-md-12">
<div class="row">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
{{ $loop->link() }}
</a>
</li>
</ul>
</div>
</div>
</div>
tapi pada
{{ $loop->links() }}
tidak bisa dengan menampikan kode error seperti ini
ErrorException (E_ERROR)
Call to a member function links() on array (View: C:\laragon\www\ios\resources\views\campus_filter.blade.php)
apakah ada solusinya
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban