Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

itsfreshmade's avatar

Dynamic Select Boxes from Database

I did a few searches but as a noob I think the results I found were a bit above my head.

So, I wrote a vanilla php inventory/cms for an automotive dealership ages ago and I'm wanting to re-write it a bit more modern (something with better performance and the ability to be consumed via api), by trade I'm a Front End Engineer but I've run the gamut in my career from backend dev, dba and anything in-between working with PHP and some c# MVC. My work these days focuses a lot on a Rails project which is why I instantly fell in love with Laravel, the migrations and seeding and concepts are very similar.

Now, my issue or quandary is that I'm writing the ListVehicle controller and related logic and I have a very complete database dump of two tables: Makes and Models that I'd like to be able to use as they've served me well over the years and are fairly up-to-date. I want to basically write a seed file for each, and when the dealership lists a new vehicle I want to be able to supply them a list of Makes, then upon selection re-query the Models data that is relationally tied to each Make. I'm digesting a ton in Laracasts but I'm also on a bit of a time crunch as child #3 is in the oven and my time will become sparse before long.

To sweeten the pot, in case anyone wants to have similar data, I'll create a new gist with a dump of the Make/Model data in case anybody would ever want/need it. The eventual goal for me is to figure out how to add Makes and Models on the fly as new things come out every year but for now just current data would be helpful. If someone helped me figure out a way to do the addition of new data I'd be like, you know, their buddy for ever?

Concluding, my apologies for being a noob to the framework and if you must bash please do ;) I look forward to learning all that I can about Laravel, it seems to be the most complete PHP framework I've seen to date (previously courted CI and Kohana).

0 likes
3 replies
itsfreshmade's avatar

Thanks @helmerdavila that could be a simple way to pull the data in for sure. I hope to figure out down the road how to insert a record for new models inline while creating a listing but for now this should get me on track!

1 like

Please or to participate in this conversation.