如何使用图像替换自定义laravel分页? 我还想在不重新加载页面的情况下获取下一组数据。 我的控制器看起来像这样。
class HomeController extends Controller
{
public function index()
{
$featured_products = DB::table('products')
->where('feature_type','=',3)
->orderBy('created_at','DESC')
->simplePaginate(4);
$latest_products = DB::table('products')
->orderBy('created_at','DESC')
->simplePaginate(4);
return View::make('pages.home')
->with(['featured_products'=>$featured_products,'latest_products'=>$latest_products]);
}
}
答案 0 :(得分:3)
最简单的方法是编辑分页的blade
文件。
首先,在你的控制台中运行:
php artisan vendor:publish --tag=laravel-pagination
然后转到resources/views/vendor/pagination/default.blade.php
,您会看到:
@if ($paginator->onFirstPage())
<li class="disabled"><span>«</span></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
@endif
...
@if ($paginator->hasMorePages())
<li><a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
@else
<li class="disabled"><span>»</span></li>
@endif
您只需将«
和»
替换为您要使用的图片。
https://laravel.com/docs/5.3/pagination#customizing-the-pagination-view
希望这有帮助!
答案 1 :(得分:0)
在5.3中你可以customize pagination views。
在其他版本中,您可以尝试使用CSS覆盖此内容,或者您可以尝试show links manually而不是使用$results->render()
方法:
$results->count()
$results->currentPage()
$results->firstItem()
$results->hasMorePages()
$results->lastItem()
$results->lastPage() (Not available when using simplePaginate)
$results->nextPageUrl()
$results->perPage()
$results->previousPageUrl()
$results->total() (Not available when using simplePaginate)
$results->url($page)