Need to convert a float or string into a currency format in Laravel? Here are two quick methods. Use PHP’s number_format() in your blade template. You can also add the following to your AppServiceProvider’s boot method. Good luck!
How do you cache efficiently in Laravel? Trying to figure out an efficient way to serve data using the least amount of resources is always a challenge to face when scaling. How much of the data to process in the front vs back end. When to cache and how to handle the scope of what … Read more
I search for this more than I thought I would. As the title suggests, the following allows you to group items of an array by its key. By Tim Cooper
Redis has a maxmemory-policy where it decides how to handle keys when memory limit is reached. noeviction will return errors when the memory limit is reached. allkeys-lru will remove less recently used keys first. volatile-lru will remove less recently used keys first that have an expiry set. allkeys-random will evict random keys. volatile-random will evict … Read more
If a user make two request in succession and you want to cancel the first, here’s how to do it in Axios. Works like a charm. Provided by NicksonYap, some iteration of iterations. https://github.com/axios/axios/issues/1361#issuecomment-417880626
I was having trouble understanding the work-flow and boilerplate of using Vuex state in my components. This article by Markus Oberlehner helped me understand how to bind elements to the state and how to use vuex-map-fields to simplify the process. Here’s the manual way. Read his post to find out about vuex-map-fields https://markus.oberlehner.net/blog/form-fields-two-way-data-binding-and-vuex/
If you are using Laravel’s firstOrCreate() method and get a unique id violation error, there is a chance you have repopulated your database retroactively in Postgres. Postgres triggers the next id in the sequence on row creation instead of on import. So it thinks the next sequence in the id field is an existing ID … Read more
You got an error. A composer memory limit error. You go to the documentation. It tells you to search through your PHP ini files and increase the memory limit. You realize that’s going to take a while depending on what env you’re using. You’d rather just copy and paste a command in the terminal. This … Read more
This is a baller gist of common useful Postgres queries.