我在尝试在laravel中创建分页时收到此错误。
1e886a45102a3e4898f23b52cd7ca771第396行中的ErrorException:调用a 数组上的成员函数links(): C:\ XAMPP \ htdocs中\ soulfy_repo \框架\资源\视图\ soulfy \ setting.blade.php)
line 396: <?php echo e($themes->links()); ?>
HomeController.php
public function getBackgroundTheme()
{
$query = DB::table('theme_background');
if (request()->has('menu')) {
$theme = DB::table('kategori_name')->where('kategori_theme', request('menu'))->first();
$query = $query->where('kategori_id', $theme->kategori_id);
}
//$model = $query->get();
$theme = $query->paginate(4);
return view('soulfy.setting', [
'themes'=>$theme,
'user' => auth()->user(),
]);
// return redirect('/home/setting' .
}
setting.blade.php
<table>
@if(isset($themes))
@foreach($themes as $m)
<tr>
<td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
<td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
<td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
</tr>
<tr>
<td><div class="box"><input type="checkbox" name="pic" value=""></div></td>
<td><input type="checkbox" name="pic" value=""></td>
<td><input type="checkbox" name="pic" value=""></td>
</tr>
@endforeach
{{ $themes->links() }}
@endif
</table>
答案 0 :(得分:1)
$theme = DB::table('kategori_name')->where('kategori_theme', request('menu'))->paginate(PAGELIMIT);
在家庭控制器中使用此功能。而不是first(); 并在你的路线中定义:定义('PAGELIMIT','4');