3 years ago

Scope Query unable to return false (zero) instead Eloquent Builder returns an object

Posted 3 years ago by Harish

Why dosen't the scoped queries return 0 when there is no data found for example on using the count() in the query and instead the Eloquent Builder returns an object. It should return false(zero) if nothing is found. Also, the Laravel Docs should be updated about this!

I am sure there would have been many important discussions about it but no positive input or reaction from Taylor or respective collaborators.

Any help or correction would be highly appreciated :) Have reported the issue on github ( https://github.com/laravel/framework/issues/10701 )

Reference to some of those discussions: https://github.com/laravel/framework/issues/5405 http://stackoverflow.com/questions/21373860/how-do-i-return-falsey-values-from-a-scope-query-in-laravel-4 http://stackoverflow.com/questions/20563166/eloquent-collection-counting-and-detect-empty

A beginner in Laravel :)

cc @bashy @pmall @bobbybouwmann

Please sign in or create an account to participate in this conversation.