I want to create a new record for a model.
I would like, instead of manually specifying every field for the model, to instead iterate over the list of fields of the model, and pull the values from the post hash if they are there
e.g. (is this possible?)
$fields = Address::attributes() // what is the actual name of this method?
foreach($fields as $field) {
if($_POST[$field) {
$input[$field] = $_POST[$field];
}
}
Address::create($input);
Here is what I use when the HTML form fields are the same as the database fields.