Skip to content

Instantly share code, notes, and snippets.

@ganapathichidambaram
Created July 25, 2021 14:29
Show Gist options
  • Save ganapathichidambaram/a071b0b55105770874c310c651e2c5fd to your computer and use it in GitHub Desktop.
Save ganapathichidambaram/a071b0b55105770874c310c651e2c5fd to your computer and use it in GitHub Desktop.
Laravel Pagination Pretty URL
@php
$links = $articles->links();
$patterns = '#\?page=#';
$replacements = '/page/';
$one = preg_replace($patterns, $replacements, $links);
$pattern2 = '#page/([1-9]+[0-9]*)/page/([1-9]+[0-9]*)#';
$replacements2 = 'page/$2';
$paginate_links = preg_replace($pattern2, $replacements2, $one);
echo $paginate_links;
@endphp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment