laravel 调用未定义的方法 Illuminate\Database\Query\Builder::render()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37136180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:45:38  来源:igfitidea点击:

Call to undefined method Illuminate\Database\Query\Builder::render()

laravellaravel-5

提问by Qasim Ali

Question like this are asked, i have searched a lot but found nothing which works for me.

像这样的问题被问到,我搜索了很多,但没有找到对我有用的东西。

Here is Controller function:

这是控制器功能:

public function showHomePage() {
    $communities = Community::all();
    $ideas = Idea::paginate(8);
    return view('publicPages.index', compact(['communities', 'ideas']));
}

Now the paginate methodis working but when in view i call the method stated in documentation Docs

现在paginate method正在工作,但在查看时我调用文档文档中所述的方法

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

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

It generates following error

它产生以下错误

Call to undefined method Illuminate\Database\Query\Builder::render()

调用未定义的方法 Illuminate\Database\Query\Builder::render()

I have also tried {!! $idea->render() !!}but the issue is same. Tried this also $ideas = DB::table('ideas')->paginate(8);

我也试过,{!! $idea->render() !!}但问题是一样的。也试过这个$ideas = DB::table('ideas')->paginate(8);

Here is view :

这是视图:

@foreach($ideas as $idea)
<div class="lst-popular-project clearfix">
  <div class="grid_3">
    <div class="project-short sml-thumb">
        <div class="top-project-info">
            <div class="content-info-short clearfix">
                <a href="{{URL::to('showidea', array($idea->id))}}" class="thumb-img">
                    <img src="{{asset($idea->idea_image)}}" alt="$TITLE">
                </a>
                <div class="wrap-short-detail">
                    <h3 class="rs acticle-title">
                        <a class="be-fc-orange" href="project">
                            {{$idea->idea_title}}
                        </a>
                    </h3>
                    <p class="rs tiny-desc">
                        by
                        <a href="profile.html" class="fw-b fc-gray be-fc-orange">
                            {{$idea->User->name}}
                        </a>
                    </p>
                    <p class="rs title-description">
                        {{$idea->idea_info}}
                    </p>
                    <p class="rs project-location">
                      <i class="icon iLocation"></i>
                      {{$idea->idea_location}}
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
@endforeach

回答by Veerendra Borra

you must replace

你必须更换

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

with
 {!! $ideas->render() !!}

$ideas variable contains from,total,page etc

$ideas 变量包含 from、total、page 等

回答by Alexey Mezenin

I guess it shoule be $ideas:

我想应该是$ideas

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