This repository contains some useful macros and extensible Macroable trait.
You can pull in the package via composer:
composer require nham24/macroable
The package will automatically register itself.
Create a LengthAwarePaginator
instance for the items in the collection.
collect($posts)->paginate(5);
This paginates the contents of $posts
with 5 items per page. paginate
accepts quite some options, head over to the Laravel docs for an in-depth guide.
paginate(int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = [])
Check if the request is an API request.
$request =
request()->isApi();