Select Page

Recently I came across an issue with a new Laravel application reading data from a SQL Server database. This database is part of a third party application and the table that my model was based on had a field added by that third party that contained non UTF-8 encoded characters. When converting attempting to convert this data for the API output it was throwing the error “Malformed UTF-8 characters, possibly incorrectly encoded”. After dumping the data returned from the query I could see that the particular field mentioned contained the characters in question. Luckily this was a field used only by the third party and not data we needed and also luckily Eloquent provides a method of removing this data from the query without having to jump through hoops or manually writing a query. By simply adding the “hidden” argument to the model Eloquent will ignore the field and all will be well in SQL town.