I am developing my first project. Things are going fairly well, but now I think I have missed a concept:
I have a 'person' model (defined relationship: hasOne state in the model).
I have a 'program' model (defined relationship: program hasOne person in the model).
I have a 'states' table (and a State model) that I want to use in quite a few locations (later when I begin to convert all my legacy code to the Laravel project), so I would like to create a partial view containing a drop down list of the states so that I can match the person's state with the value from the 'list table' of states.
What is the best way to make this code generic so that it can be used anywhere and feed (in this case) the person's state into the logic so that on my view where I am using the ProgramController I can have a drop down list of states and match the "selected=selected" attribute to the correct value?
I thought of adding the code to my Program controller as a method (State::get()), but realized it certainly won't be generic to use anywhere the 'state' drop down needs to be displayed.