加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – Laravel 5.2分页

发布时间:2020-12-14 19:49:21 所属栏目:大数据 来源:网络整理
导读:我用这种方式为我的网站做了一个分页,但我仍然收到错误!我试图解决,我搜索了很多,没有找到解决方案.我希望你能帮助我. 控制器 – class ContentController extends MasterController { public function content() {$content = content::all()-paginate(10);
我用这种方式为我的网站做了一个分页,但我仍然收到错误!我试图解决,我搜索了很多,没有找到解决方案.我希望你能帮助我.

控制器 –

class ContentController extends MasterController {


    public function content() {
$content = content::all()->paginate(10);  
$content->setPath('content'); //Customise Page Url
return view('content.boot',compact('content'));

}
}

查看 –

@extends('master')
@section('content')

@if(count($content) > 0 )

@foreach($content as $row)

<video width="330" controls>
    <source src="{{ asset('videos/' . $row['video'] )}}" type="video/mp4">
</video>
@endforeach
@endif

{!! $content->render() !!} 

@endsection

路线 –

Route::get('/','ContentController@content');

错误 –

BadMethodCallException in Macroable.php line 81:
Method paginate does not exist.

删除all()函数,你的代码应该是:
$content = content::paginate(10);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读