If you’re like me and like to use select statements to return specific columns. You’ll be happy to know that Eloquent allow you to use select column as alias just like in SQL. Which can be make things a breeze, depending on what you are doing. Remember to use the dot syntax to specify a … Read more
If you want to know how many times your Laravel query is hitting the database you can use this snippet by @Tarasovych from StackOverflow. Pretty handy!
Various ways to set value if the value does not exist in PHP. The whole discussion summarized nicely at the end by @ben221199:
The Problem Do you see a json ajax response instead of the page you were expecting when hitting the back button? This can happen if you use the the same routes for your html and ajax like so. The problem is that the browser (depending on the browser) decides to cache data that is passed … Read more
This is a shoutout to Laravel’s Query Builder method distinct(). I feel sad and embarrassed that I didn’t know about it sooner. There are a lot of instances where I need to get a column’s unique values. And instead of using groupBy() and wasting a lot of resources. You can use distinct(), which will search … Read more
This is a baller gist of common useful Postgres queries.
If you’re working with Alpine JS, as some Tailwind users do, and want to translate the transition animations to Vue, here’s a handy side by side comparison that will help you get the job done! Just kidding. They’re stacked.
The Story (skip if ya just want the code) I’ve fussed with this problem for weeks. If you need to import massive amounts of csv data (100k to 10mil) to your Laravel site there’s a lot of broken information. Some of it is outdated, others are just bits and pieces. But here’s generally how the … Read more