Skip to content

Commit

Permalink
[8.x] Allow tap() on Paginator (#37682)
Browse files Browse the repository at this point in the history
Before

```php
$posts = App\Models\Post::search('Laravel')->paginate();

$posts->load('user');

return $posts;
```

After

```php
return App\Models\Post::search('Laravel')
    ->paginate()
    ->tap(fn ($posts) => $posts->load('author'));
```

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Jun 14, 2021
1 parent f60d3da commit 1472e3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Pagination/AbstractCursorPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Support\Traits\Tappable;

/**
* @mixin \Illuminate\Support\Collection
*/
abstract class AbstractCursorPaginator implements Htmlable
{
use ForwardsCalls;
use ForwardsCalls, Tappable;

/**
* All of the items being paginated.
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Pagination/AbstractPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Support\Traits\Tappable;

/**
* @mixin \Illuminate\Support\Collection
*/
abstract class AbstractPaginator implements Htmlable
{
use ForwardsCalls;
use ForwardsCalls, Tappable;

/**
* All of the items being paginated.
Expand Down

0 comments on commit 1472e3c

Please sign in to comment.