Laravel offers two new useful debugging methods
dd() as part of Laravel 5.5 version release. These methods are added to Collections, it means you can call
dd() on collection instances.
In previous Laravel versions, when debugging collections we’d assign a variable to a collection then keep dumping the variable as we altered the collection. This won’t be the case anymore in Laravel 5.5 as we can now call
dump() directly on a collection instance. These methods are making debugging a lot easier and simple.
Imagine you had a collection of users which went through a series of transformations and we wanted to inspect the collection at each step, then this will do:
$users= Users::all(); $users->dump() ->sortBy('created_at') ->dump() ->take(10) ->pluck('name') ->dd() // here dd will dump the resulst and stops the execuation. ->take(1);
NOTE: There is a difference between calling dump() and dd() on a collection. dump() outputs the results at that moment and then continues processing while dd() stops the process immediately and dumps out the results (dd stands for dump and die)