I have a SQlite database with 50 states and I want to create an input for each of the 50 states. The input would update the individual states' "totals" in the database with the number input in it's text field. I have created a form which is about 110 lines long, but I am certain I could do this via iteration in blade templating. I just don't know how to make the form fields correspond to one particular state in the array of states.
The DB has an Eloquent model named Distributors and looks as follows:
ID | State | Total
1 | PA | 0
I am pretty sure I could make this thing work if I created separate input values for all fields and used the
DB::table('distributors')->where('state', '==', 'PA')
->update(array('total' => 'Input::get('total')'));
But there has to be an easier, more automated way... any direction would be appreciated.
Aucun commentaire:
Enregistrer un commentaire