Category: Database, container

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.

Related Articles