我有一个函数,即使用joining
获取图片表的所有属性orderBy
并需要添加paginate
这是我的功能
public function show_all()
{
$properties = PropertyDetail::where('active', 1)->with('propImages')->paginate(15)
->orderBy('id', 'DESC')
->get();
return View::make('portal.properties.view_all', compact('properties'));
}
在我看来,我得到了
call_user_func_array()期望参数1是有效的回调, class'Linuminate \ Support \ Collection'没有方法'orderBy'
当我删除orderBy('id', 'DESC')->get()
时,我尝试了另一件事
它有效,但当我试图将{{ $prop->links() }}
放在我得到的视图中时
调用未定义的方法Illuminate \ Database \ Query \ Builder :: links()
这是我的观点的样子
@foreach($properties as $prop)
<div class="property col-xs-12 col-sm-6 col-md-4">
<div class="image">
<div class="content imgContainer">
{{ HTML::link('property-details/'.$prop->id, '') }}
@foreach($prop->propImages->slice(0, 1) as $image)
{{ HTML::image('images/propertyImages/'.$image->image, $prop->title) }}
@endforeach
</div>
<div class="price"> OMR. <span class="priceNumber"> {{ $prop->price }}</span></div>
</div>
<div class="title">
<h2>{{ HTML::link('', $prop->title, array('title'=>'$prop->title')) }}</h2>
</div>
<div class="location">{{ trans('location.'.$prop->propLocation->city) }}</div>
<div class="bathrooms">
<div class="content">{{ $prop->bathroom }}</div>
</div>
<div class="bedrooms">
<div class="content">{{ $prop->bedroom }}</div>
</div><!-- /.bedrooms -->
<div class="receptionRoom">
<div class="content">{{ $prop->dining_room }}</div>
</div>
</div>
@endforeach
{{ $prop->links() }}
答案 0 :(得分:4)
正确的语法是:
$properties = PropertyDetail::where('active', 1)
->with('propImages')
->orderBy('id', 'desc')
->paginate(15);