July 8, 2020

What is Value Object Casting in Laravel?

Laravel 7 introduced Custom Eloquent Casts. Next to primitive types, such as json, it is also possible to cast values that form a compound to objects. This is an effective way to introduce value objects to your Eloquent models, and make your data more...


April 19, 2020

How to Use Stub Customization in Laravel

Laravel 7 came with a new feature, stub customization. Stub customization gives the ability to modify the stub files that are used when creating classes such as controllers and tests with the artisan make command. In this guide I will try to...


Run Tests With PHP Artisan Test cover image

March 29, 2020

Run Tests With PHP Artisan Test

Since the release of Laravel 7.x, you can run you tests by executing as an alternative to running your tests with the phpunit command. This command will run all your tests, until the first test that fails. The major differences from...


Sign up for the newsletter

May 25, 2021

How to Remove Null Values From a Collection in Laravel

Sometimes, you may end up with a collection that contains null values. Removing those null values from the collection can be done very smoothly with the filter...


May 14, 2021

Sending Laravel Notifications Without Notifiable

Notifications in Laravel are typically used to notify users in your application. Users do not have to be the App\Models\User model, but can be any model that includes the...


February 11, 2021

Six Ways to Get Raw SQL Output From Query Builder in Laravel

When working with Laravel, you will probably use the query builder in order to create and run database queries. Sometimes you want to see the raw SQL output of a query, for example when you are...


November 25, 2020

How to Split a Collection in Laravel 8

Since Laravel 8.16, it is possible to split a collection into chunks in two different ways. The first one, that already existed, is the split method: This method breaks a collection into a...


November 16, 2020

Excluding Routes From a Catch-All Route by Using Regex in Laravel

When creating a catch-all route in Laravel, you might encounter conflicts with others routes in your application. In this post I would like to describe how you can resolve some of these conflicts....


October 1, 2020

Practical Options for the Route List Command in Laravel

When you want to show a list of all registered routes in your application, you can use the php artisan route:list command. The output of this command can be a bit confusing when you are...