I am currently trying to insert the value of fields to a table. However, this error keeps coming up:
ksort() expects parameter to be array, integer given
Here is the code in my controller:
public function store(Request $request)
{
$input = $request->all();
$businessfunction = BusinessFunction::create($input);
$fields = Input::get('fields_');
foreach($fields as $field) {
DB::table('field_instances')->insert(
['value' => $fields, 'businessfunction_id' => $businessfunction->id]
);
}
I thought putting the information in a foreach loop would fix it, but I'm still getting the same error. Any assistance would be appreciated!
here i think it should be $field ?
['value' => $field, 'businessfunction_id' => $businessfunction->id]
astroanu said:
here i think it should be $field ?
['value' => $field, 'businessfunction_id' => $businessfunction->id]
Even when I use 'field' it doesn't work. It gives me the same error.
To diagnose this do this
['value' => json_encode($field), 'businessfunction_id' => $businessfunction->id]
and see what is got inserted in db.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community