My first Laravel Nova project - Work Journal December 1, 2023

Last year I started work on a large project setting up a recycling location search tool (as a subcontractor) for the RCBC (Recycling Council of British Columbia). Their old informational website and search tool were both built on Drupal and they were moving to a new WordPress site created by our friends at Forge & Smith but the search tool, affectionately known as recyclepedia also needed to be rebuilt and I was asked if I could take on that challenge.

The recyclepedia is actually primarily JavaScript widget and API that handles selecting a material (that someone wants to recycle) and a geographical location and returns a list of places that the material can be recycled at. The list of which materials can be recycled at which locations is updated daily by RCBC so the systems database needs to update every day to ensure accurate results. This widget is used on a handful of websites and needed to maintain backwards compatibility with existing implementations.

I chose to create the project in Laravel and used Laravel Nova for the first time to speed up the backend dashboard scaffolding process. Laravel Nova makes it really easy to create administration pages for managing your content, users, and permissions. I had the existing Drupal database and PHP code to help with the complex queries but still had to plan and implement a proper Laravel relational database model that was different than the old Drupal way of storing the information.

The project consisted of several major components:

  • The daily import of a spreadsheet of location and material data
  • The backend where admins can view all the location and material setup and edit some content types that are not a part of the daily import spreadsheet
  • Reporting tools for them to see what is being searched for and what kind of results are being returned to visitors
  • The actual JavaScript widget used on a variety of sites that needs to run from our new API but not really behave or look different than the existing widget.
  • The various API endpoints that the widget communicates with, these query the database and return JSON results in the exact same format as the old Drupal API would.

It was very helpful to have the old Drupal code that performed the mySQL database queries because for some of the functions I could take that old code, change some column and variables names, and the code would properly return the expected results. This definitely saved me a bunch of hours that I would have had to spend figuring out how to search for nearby locations by doing algebraic math involving cos, sin, radians, distances, latitude and longitude.

The tool gets quite a bit of traffic and when we first launched I was a little worried about stability and performance but things have been running well and over the last few months we have started working on some more enhancements to the projects reporting and frontend widget.

I should probably tell you about how I had my own Google Maps API key set up on the tool for geocoding the locations to the latitude and longitude coordinates. This isn’t an issue if it is only geocoding a few addresses a day or even a few thousand a month but it was doing thousands of locations every day and I ended up with a Google Cloud bill for $482.42 last December. We quickly switched to using RCBC’s own Google Cloud account and then adjusting the code so that it was not geocoding the addresses every day, it would use existing geocode data if it exists and then once in a while they can clear out old geocode information as needed.

Overall, this has been a fantastic project and I definitely would enjoy doing more projects that utilize Laravel Nova, Laravel Jetstream, Inertia, and Tailwind. These tools make web application development and styling enjoyable and efficient.





The complete Work Journal series:
1. Week ending January 25th, 2019
2. Week ending February 1st, 2019
3. Week ending February 8th, 2019
4. Week ending February 15th, 2019
5. Week ending February 22nd, 2019
6. Week ending March 1st, 2019
7. Week ending March 8th, 2019
8. Week ending March 15th, 2019
9. Week ending March 22nd, 2019
10. Week ending March 29nd, 2019
11. Week ending April 5th, 2019
12. Week ending April 12th, 2019
13. Week ending April 19th, 2019
14. Week ending August 9th, 2019
15. Week ending September 20th, 2019
16. Week ending September 27th, 2019
17. Week ending December 6th, 2019
18. Week ending October 2nd, 2020
19. Week ending April 2nd, 2021
20. Coding API integrations in Twilio Studio - Work Journal May 8, 2021
21. Trudging through a complex theme implementation - Work Journal October 29, 2021
22. Creating custom Duda widgets - Work Journal December 10, 2021
23. My first Laravel Nova project - Work Journal December 1, 2023
24. Let's talk about Statamic - Work Journal January 12, 2024