2016-10-25 7 views
2

カスタムLaravelページネーションを画像に置き換えるにはどうすればよいですか? ページを再読み込みせずに次のデータセットを取得したいと思います。 コントローラは次のようになります。 5.3することができますcustomize pagination viewsLaravel 5.3、改ページリンク(<< and >>)を画像に置き換えます。

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

。あなたはCSSでこれを上書きしようとすることができるか、代わりに$results->render()メソッドを使用してのshow links manuallyに試みることができる他のバージョンでは

$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) 
3

最も簡単な方法は、単にページネーションのためのbladeファイルを編集することです。

php artisan vendor:publish --tag=laravel-pagination 

その後resources/views/vendor/pagination/default.blade.phpに行き、あなたが表示されます:

@if ($paginator->onFirstPage()) 
    <li class="disabled"><span>&laquo;</span></li> 
@else 
    <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li> 
@endif 

... 

@if ($paginator->hasMorePages()) 
    <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li> 
@else 
    <li class="disabled"><span>&raquo;</span></li> 
@endif 

あなたはちょうどあなたが使用したい画像を&laquo;&raquo;を置き換えることができ、あなたのコンソールの実行にまず

、 。

https://laravel.com/docs/5.3/pagination#customizing-the-pagination-view

は、この情報がお役に立てば幸い!

関連する問題