DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

Making the most of your Laravel dumps

3 years ago fidum.uk

Summary: This is a summary of an article originally published by Fidum. Read the full original article here →

Laravel has a number of convenient methods to help speed up your development. When developing you sometimes need to see what an object or variable contains to make sure the code is doing what you expect.

Now you can just chain the dump method onto the end of your model query, and you will get the same output.

If you call the dump function on an Eloquent Collection you will see it output any array of models: App\Models\Post::where('author', 'Bob')->get()->dump(); array [ 0 => App\Models\Post {#1745 #attributes: array:7 ["id" => 1 "title" => "Poop is a crap palindrome...""author" => "Bob" #... ]}, 1 => App\Models\Post { }]

When you call any of the above dump methods in a Controller method or Route closure Laravel will render the output for you.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com