You are looking at posts in 'Laravel'

With all the various sources for news about Laravel I still think there is more room for a small newsletter to inform about the weekly occurring changes in the Laravel ecosystem. Without further words let's dive right in! With Laravel 7 we got the custom Casts feature. In v7.10 Voidgraphics got us the artisan make:cast command. For those of you who are interested in how this feature was implemented, take a look at the changed files and see how easy Laravel makes it to create a...

When debugging and you are not sure whether the cache is part of the issue it's always nice to temporarily disable it to get to the bottom of what's going on. What many people do not know and what isn't documented in the Laravel documentation is the option to disable the cache by using the Illuminate\Cache\NullStore. There is not much to do to enable the null or none cache driver. You only have to tweak the config/cache.php and modify your...

Today my client asked me to only allow the user to view models in a specific state. The application uses a custom engine for the user interaction and Laravel Nova in the backend. Since the code responsible for the user interaction is quite huge and I didn't want to look up every model query and apply a custom query I figured out adding a global scope would be the easiest way to accomplish this. Unfortunately, we have quite a few jobs in the backend which require to access all models and lazy...

EDIT: It seems like I was unable to think of the simplest of all solutions would suffice my needs. Turns out a simple where() call does the job - sorry for bothering! You can still read on and take the following as an example on how to use macros! In one of my recent client projects, I had to query the latest records from the last few hours/minutes. I thought I'd be able to leverage the existing whereDate() method from Laravel's...

Sign up for my newsletter

If you enjoyed this article, sign up for my newsletter to be the first to know when a new article is published.