【发布时间】:2016-10-23 22:30:51
【问题描述】:
为了在 l5 中使用 paginate 进行无限滚动,我发现了很多文章,但它们都使用这个 paginate() 函数,因为它们使用来自 db 的结果集,但我从 googlefontapi 获取数据作为 json 所以当我使用 paginate( ) 在 json 中它会导致错误,也会在数组中。我的代码
public function index(){
$url = "https://www.googleapis.com/webfonts/v1/webfonts?key=!";
$result = json_decode(file_get_contents( $url ))->paginate(10);
$font_list = "";
foreach ( $result->items as $font )
{
$font_list[] = [
'font_name' => $font->family,
'category' => $font->category,
'variants' => implode(', ', $font->variants),
// subsets
// version
// files
];
}
return view('website_settings')->with('data', $font_list);
}
错误是
Call to undefined method stdClass::paginate()
还有其他方法可以实现吗
【问题讨论】:
标签: laravel laravel-5 pagination infinite-scroll