Level 73
You can use when() for that:
DB::table('users')->select('first_name')
->when($city_id > 0, function($query) use ($city_id) {
$query->where('addresses.city_id',$city_id);
})->get();
More here: https://laravel.com/docs/8.x/queries#conditional-clauses