Laravel 8 throws me the error array_merge(): Expected parameter 2 to be an array, int given when updating a record in the database. However, if you update the registry and I don't see where the problem is. I leave you the code to see if you can tell me what the problem is.
Controller:
try {
$showclient = Client::findOrfail($id);
$showclient->update(
[
'cif' => $request->cif,
'company' => $request->company,
'corporateaddress' => $request->corporateaddress,
'postalcode' => $request->postalcode,
'locality' => $request->locality,
'province' => $request->province,
'telephone' => $request->telephone,
'mobile' => $request->mobile,
'type' => $request->type,
'contactname' => $request->contactname,
'telephonecontact' => $request->telephonecontact,
'mobilecontact' => $request->mobilecontact,
'emailcontact' => $request->emailcontact,
]
);
Log::info(
'¡¡CLIENTE ACTUALIZADO!!.
Actualizados los datos del cliente con ID: '
. $request->id
);
return view('admin.clients.show', $showclient->id)->with(
'success',
'Los datos del cliente indicado han sido actualizados correctamente.'
);
} catch (\Throwable $th) {
Log::error(
'¡¡ERROR EN ACTUALIZACIÓN DE CLIENTE!!, Operación Cancelada.
Mensaje de error:' . $th->getMessage()
);
return redirect()->route('admin.clients.index')->with(
'error', 'Error en el proceso de actualización.
Contacte con el administrador del sistema. Error: '
. $th->getMessage()
);
}
Thanks in advance, regards.
The problem is in the return of the view
The second parameter of the helper
view
must be an array and you are sending an int ($showclient->id)try like this (['id' => $showclient->id]) :