mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
3.2.4
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -15,6 +17,29 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
/**
|
||||
* Paginate a standard Laravel Collection.
|
||||
*
|
||||
* @param int $perPage
|
||||
* @param int $total
|
||||
* @param int $page
|
||||
* @param string $pageName
|
||||
* @return array
|
||||
*/
|
||||
Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') {
|
||||
$page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
|
||||
return new LengthAwarePaginator(
|
||||
$this->forPage($page, $perPage),
|
||||
$total ?: $this->count(),
|
||||
$perPage,
|
||||
$page,
|
||||
[
|
||||
'path' => LengthAwarePaginator::resolveCurrentPath(),
|
||||
'pageName' => $pageName,
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user