Home /

Blog

Filtered on: Eloquent Unset

Blog

My random ramblings

Below you can read various blog posts about Laravel, Vue.js or other techniques. That depends on my mood.

Loading blogposts...

Decrease memory usage with the toBase() function

Laravel offers a lot of convenient functions. Using an ORM like Eloquent, a function like BlogPost::all(), not only fetches all blog posts from the database, but also prepares them as Models. This is very convenient if you need to have access to model functions. But what if you do not require these model functions, how can we decrease memory usage and improve performance?

Scopes to custom QueryBuilders

As you might be aware, reusing certain query scopes is fairly straightforward using Local scopes. But it feels a bit dirty to bother our models with this logic, especially since every function has to be prefixed with scope. Fortunately, there is an easier way to define these reusable scopes using separate QueryBuilder classes.