Laravel dropdown list without empty values I'm creating dropdown list from all possible cities in database, all cities are distincted. 

$city = DB::table('contacts')-&gt;distinct('city')-&gt;lists('id', 'city'); 

^ Extracts all possible cities, however it also extract empty string ['' =&gt; '95]. 

How I can forbid retrieving empty city ? 

I tried using $city = DB::table('contacts')-&gt;whereNotNull('city')-&gt;distinct('city')-&gt;lists('id', 'city'); But didn't helped. My code looks like this now.

    $city = DB::table('contacts')-&gt;distinct('city')-&gt;lists('id', 'city');
    unset($city['']);
    array_unshift($city, 'Select city');


How can I improve it ?
I'm assuming that you are using the whereNotNull() because in addition to allowing empty strings, you allow null values?

That being said, you could always modify your code to use the specific where() clause. This can take an array as input and you can specify both the empty string and NULL.

$city = DB::table('contacts')-&gt;distinct('city')-&gt;lists('id', 'city')-&gt;where(function($query) {
    $query-&gt;where('contacts.city', '!=', '')
        -&gt;orWhere('contacts.city', '!=', null);
})


There's a very good SO post here about multiple where clause queries.