I am trying to create pagination in laravel and receiving error.
ErrorException in 1e886a45102a3e4898f23b52cd7ca771 line 369: Call to undefined method stdClass::links() (View: C:\xampp\htdocs\soulfy_repo\framework\resources\views\soulfy\setting.blade.php)
This is my codes:
HomeController.php
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
....
public function getBackgroundTheme()
{
$query = DB::table('theme_background')->paginate(4);
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();
return view('soulfy.setting', [
'themes'=>$model,
'user' => auth()->user(),
]);
}
ErrorException in 1e886a45102a3e4898f23b52cd7ca771 line 375: Call to undefined function links() (View: C:\xampp\htdocs\soulfy_repo\framework\resources\views\soulfy\setting.blade.php)
ErrorException in 1e886a45102a3e4898f23b52cd7ca771 line 396: Call to a member function links() on array (View: C:\xampp\htdocs\soulfy_repo\framework\resources\views\soulfy\setting.blade.php)
line 396:
<?php echo e($themes->links()); ?>
Why I cannot paginate?
Someone mentions that I should remove the ->first() calling method since only return a single element.
This is strange that I receive many pictures shown as a result. It's a picture gallery which is based under a single selected category.