Skip to content

Commit 01f6307

Browse files
Add debug function to Collection like dump (#1115)
1 parent 233c106 commit 01f6307

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ There are also helper functions available for the most common calls:
132132
// All arguments will be dumped as a debug message
133133
debug($var1, $someString, $intValue, $object);
134134

135+
// `$collection->debug()` will return the collection and dump it as a debug message. Like `$collection->dump()`
136+
collect([$var1, $someString])->debug();
137+
135138
start_measure('render','Time for rendering');
136139
stop_measure('render');
137140
add_measure('now', LARAVEL_START, microtime(true));

src/ServiceProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Contracts\Http\Kernel;
1010
use Illuminate\Routing\Router;
1111
use Illuminate\Session\SessionManager;
12+
use Illuminate\Support\Collection;
1213

1314
class ServiceProvider extends \Illuminate\Support\ServiceProvider
1415
{
@@ -58,6 +59,11 @@ function ($app) {
5859
);
5960

6061
$this->commands(['command.debugbar.clear']);
62+
63+
Collection::macro('debug', function () {
64+
debug($this);
65+
return $this;
66+
});
6167
}
6268

6369
/**

0 commit comments

Comments
 (0)