Skip to main content


Using a trait to add UUID to a Laravel 5 Model

The past weeks i’m spending my free time with building a application using Laravel 5.4, but I wanted to use an UUID on a few models. So I did what I always do, go look on packagist to find if somebody already done that work for me. And they did, but what I found was either over engineered and / or implementing their own logic of creating and validating the UUID. But I know that Laravel comes with the UUID package of Ben Ramsey so that kind of bugged me a lot. Why duplicate logic when there is a battle tested library reachable within the /vendor folder? This was a good opportunity to dive in the world of Laravel models,and especially the events ( ) that models fire off. Sure I could’ve done the same per mo...