Home / Snippets / Laravel Chain dd in Collection
Laravel Chain dd in Collection cover

Laravel Chain dd in Collection

281

3 years ago

0 comments

Often time the Die and Dump "dd()" helper method is used alone to print out all of the data of a variable to the browser.
$posts = Post::where('read_time', '>', 8)
    ->get();

dd($posts);

Instead of dd the result like above, you can chain the collection with "dd()" at the end of the collection query. By doing so the code is much more expressive and straight forward.
$posts = Post::where('read_time', '>', 8)
    ->get()
    ->dd();
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this