This short eloquent firstOrCreate function is not working on linux web server. I've tried in localhost on windows and its working fine but as you can see the exception below, query string is not encoded properly.
Running on Laravel 5.8 PHP 7.3 with MySQL 5.7
$search = SearchHistory::firstOrCreate([
'ip_address' => request()->ip(),
'data' => json_encode(request()->query())
], [
'user_id' => auth()->id() ?? 0,
'user_agent' => request()->userAgent()
]);
The formatted query should be like:
select * from `search_histories` where (`ip_address` = '127.0.0.1' and `data` = '{\"inc_surrounding\":\"on\",\"address\":\"Surry Hills, New South Wales, Australia\"}') limit 1
But i'm getting this error..
Illuminate \ Database \ QueryException (HY000)
SQLSTATE[HY000]: General error: 2036 (SQL: select * from `search_histories` where (`ip_address` = 27.34.72.242 and `data` = {"address":"Surry Hills, New South Wales, Australia","radius":"10","price":{"min":"100000","max":"800000"},"bedroom":"0","bathroom":"0","parking":"0","land_size":{"min":null,"max":null}}) limit 1)