$lists = DB::table('searches')->orderBy('query', 'DESC')->paginate(15);
@foreach ($lists as list)
<div> {{$list->name}} </div>
@endforeach
I did write this query and It shows:
Apple Apple Apple Apple Apple Apple Banana Banana Banana Grapes Grapes Orange ....
I want to show only the names of the fruits having an overall count of occurences greater than 3 (if count>3) I used:
DB::select('SELECT query, count(*) as count FROM searches GROUP BY query HAVING count > 3');
but in view file I cannot count by $lists->count()
Error: Call to a member function count() on array
I want my output as:
Apple Banana ...
and $lists->count() as 2
Since Orange and Grapes count < 3 so they won't be included in the output.