Posts Learn Components Snippets Categories Tags Tools About
/

Laravel Chain dd in Collection

Learn how to chain dd in Laravel collection

Created on Aug 11, 2021

266 views

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();

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

Load comments for Laravel Chain dd in Collection

)