It shows "General error: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column 'proj.conferences.start_date' which is not in SELECT list; this is incompatible with DISTINCT (SQL: select distinct city from conferences where city LIKE %new% order by start_date asc)".
So you need to add start_date in the fields that you are getting. Right now, you are telling it to ONLY get the city column here ->get(['city']), but then you're telling it to sort by start_date, but you didn't select it.
Thanks, but also dont shows nothing, if the user introduce for example "New" dont appears Newcastle with that query. But it appears with only " $cities = Conference::where('city', 'LIKE', '%'.$search.'%')->distinct()->get(['city']);
".
The SQL is sound so if you do a dd($cities); you will see the result you expect.
It's somewhere else in that mess of code that I have no clue of what you are trying to do with that messes the whole thing up.
Do a dd($request); to just to see that you have a termthere.
The search() method is the method for the autocomplete jquery ui search. For example, when the user enter 3 letters in the autocomplete search field it appears the results.
For example if the user introduce 3 letters for a conference name like "con" it appears "conference 1", "Conference 2", etc.
If the user introduces the name of a city like "New" it appears "Newcastle".
The $request when the user introduces for example "New" is:
With " $cities = DB::raw("SELECT city, min(start_date) FROM conferences WHERE city LIKE '%" . $search . "%'
GROUP BY city ORDER BY min(start_date) ASC");" shows: