Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Cache delete handler for Laravel 5.1 pagination.
- *
- * @array list of laravel cache keys
- * @param int $totalResults Total results for pagination
- * @param int $perPage Page results
- * @return Response
- *
- * You need to cache your pages with this key pattern:
- * Cache::rememberForever('key.' . $currentPage , function(){});
- * Default $currentPage must be 1
- * if(!$currentPage)$currentPage = 1
- */
- public function clearPaginateCache(array $array, $totalResults, $perPage)
- {
- $totalPages = ceil($totalResults/$perPage) + 1;
- foreach ($array as $key => $value)
- {
- for($x = 1; $x <= $totalPages; $x++)
- {
- Cache::forget($value . "." . $x);
- }
- }
- }
Add Comment
Please, Sign In to add comment