This however works fine with the MySQL driver. When using SQLite as the database driver, has
returns an empty collection because the count gets wrapped in quotes. You may use the DB::raw
method to pass the count as a raw expression.
$posts = Post::has('comments', '>=', DB::raw(1))->get();
Edit: As patricus affirmed this issue was affecting only installations prior to Laravel 4.1.25. You don't need to use this workaround with newer versions.