{"action":"opened","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/7643","labels_url":"https://api.github.com/repos/laravel/framework/issues/7643/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/7643/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/7643/events","html_url":"https://github.com/laravel/framework/issues/7643","id":59223719,"number":7643,"title":"Unclear behavior for query scope returning null/empty/false things","user":{"login":"alexandre-butynski","id":671662,"avatar_url":"https://avatars.githubusercontent.com/u/671662?v=3","gravatar_id":"","url":"https://api.github.com/users/alexandre-butynski","html_url":"https://github.com/alexandre-butynski","followers_url":"https://api.github.com/users/alexandre-butynski/followers","following_url":"https://api.github.com/users/alexandre-butynski/following{/other_user}","gists_url":"https://api.github.com/users/alexandre-butynski/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandre-butynski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandre-butynski/subscriptions","organizations_url":"https://api.github.com/users/alexandre-butynski/orgs","repos_url":"https://api.github.com/users/alexandre-butynski/repos","events_url":"https://api.github.com/users/alexandre-butynski/events{/privacy}","received_events_url":"https://api.github.com/users/alexandre-butynski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-27T11:21:40Z","updated_at":"2015-02-27T11:21:40Z","closed_at":null,"body":"I want to write a query scope that return an array of things (id => name) and not the query builder. To simplify, it's like if I want to overwrite the `lists` method. The issue come when I return an empty array (and also occur when I return, `false`, `0` or `\"\"`).\r\n\r\nThat's because the `callScope` method return the query builder itself when the method return something falsy :\r\n\r\n```PHP\r\nprotected function callScope($scope, $parameters)\r\n{\r\n\tarray_unshift($parameters, $this);\r\n\r\n\treturn call_user_func_array(array($this->model, $scope), $parameters) ?: $this;\r\n}\r\n```\r\n\r\nFirst, I thought it was a bug and want to propose a PR but the stub class in the current test case confused me. It shows that we can use a query scope and returning nothing. This is an undocumented possibility  :\r\n\r\n```PHP\r\nclass EloquentBuilderTestScopeStub extends Illuminate\\Database\\Eloquent\\Model {\r\n\tpublic function scopeApproved($query)\r\n\t{\r\n\t\t$query->where('foo', 'bar');\r\n\t}\r\n}\r\n```\r\n\r\nThen... is that an heresy to return something else than a query builder ? Can we build something more robust ? Am I missed an other way to do something like that ?\r\n\r\nI think that it could be really great to build query scopes that act more or less like `find`, `count`, `exists` or `lists` methods. "}}