{"action":"closed","number":116,"pull_request":{"url":"https://api.github.com/repos/laravel/scout/pulls/116","id":90671093,"html_url":"https://github.com/laravel/scout/pull/116","diff_url":"https://github.com/laravel/scout/pull/116.diff","patch_url":"https://github.com/laravel/scout/pull/116.patch","issue_url":"https://api.github.com/repos/laravel/scout/issues/116","number":116,"state":"closed","locked":false,"title":"If search is empty return a regular query.","user":{"login":"jordanramstad","id":9621471,"avatar_url":"https://avatars.githubusercontent.com/u/9621471?v=3","gravatar_id":"","url":"https://api.github.com/users/jordanramstad","html_url":"https://github.com/jordanramstad","followers_url":"https://api.github.com/users/jordanramstad/followers","following_url":"https://api.github.com/users/jordanramstad/following{/other_user}","gists_url":"https://api.github.com/users/jordanramstad/gists{/gist_id}","starred_url":"https://api.github.com/users/jordanramstad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordanramstad/subscriptions","organizations_url":"https://api.github.com/users/jordanramstad/orgs","repos_url":"https://api.github.com/users/jordanramstad/repos","events_url":"https://api.github.com/users/jordanramstad/events{/privacy}","received_events_url":"https://api.github.com/users/jordanramstad/received_events","type":"User","site_admin":false},"body":"The reason I bring this up is because this is how I initially wrote the query in my controller.\r\n\r\n```\r\n$models = Model::search($request->get('search', null))->paginate($request->get('limit', 25));\r\n```\r\n\r\nBasically if the search is empty (at least with the elasticsearch driver) it will return an empty collection. This is not really what you would expect, if the search is empty it should return all records. I have not used algolia so I am not sure if the same behavior exists there.\r\n\r\nMy solution here is just a simple one. It will return a regular query if the search is empty, I don't think it covers every possibility though.\r\n\r\nIf this is not done then you have to first check if search exists and make the `$models` variable use search or just a regular collection, this just saves you a few lines of code in your controller, but I do see some issues that might come up because of it (functions available in queries not being available in scout).","created_at":"2016-10-24T18:54:44Z","updated_at":"2016-10-24T19:50:25Z","closed_at":"2016-10-24T19:50:25Z","merged_at":null,"merge_commit_sha":"3bc6fdfdde83b933818519f948e1899539a63aab","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/laravel/scout/pulls/116/commits","review_comments_url":"https://api.github.com/repos/laravel/scout/pulls/116/comments","review_comment_url":"https://api.github.com/repos/laravel/scout/pulls/comments{/number}","comments_url":"https://api.github.com/repos/laravel/scout/issues/116/comments","statuses_url":"https://api.github.com/repos/laravel/scout/statuses/83aca950dfd45deab9b390969687bc49ef0b027c","head":{"label":"jordanramstad:master","ref":"master","sha":"83aca950dfd45deab9b390969687bc49ef0b027c","user":{"login":"jordanramstad","id":9621471,"avatar_url":"https://avatars.githubusercontent.com/u/9621471?v=3","gravatar_id":"","url":"https://api.github.com/users/jordanramstad","html_url":"https://github.com/jordanramstad","followers_url":"https://api.github.com/users/jordanramstad/followers","following_url":"https://api.github.com/users/jordanramstad/following{/other_user}","gists_url":"https://api.github.com/users/jordanramstad/gists{/gist_id}","starred_url":"https://api.github.com/users/jordanramstad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordanramstad/subscriptions","organizations_url":"https://api.github.com/users/jordanramstad/orgs","repos_url":"https://api.github.com/users/jordanramstad/repos","events_url":"https://api.github.com/users/jordanramstad/events{/privacy}","received_events_url":"https://api.github.com/users/jordanramstad/received_events","type":"User","site_admin":false},"repo":{"id":71819866,"name":"scout","full_name":"jordanramstad/scout","owner":{"login":"jordanramstad","id":9621471,"avatar_url":"https://avatars.githubusercontent.com/u/9621471?v=3","gravatar_id":"","url":"https://api.github.com/users/jordanramstad","html_url":"https://github.com/jordanramstad","followers_url":"https://api.github.com/users/jordanramstad/followers","following_url":"https://api.github.com/users/jordanramstad/following{/other_user}","gists_url":"https://api.github.com/users/jordanramstad/gists{/gist_id}","starred_url":"https://api.github.com/users/jordanramstad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordanramstad/subscriptions","organizations_url":"https://api.github.com/users/jordanramstad/orgs","repos_url":"https://api.github.com/users/jordanramstad/repos","events_url":"https://api.github.com/users/jordanramstad/events{/privacy}","received_events_url":"https://api.github.com/users/jordanramstad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jordanramstad/scout","description":null,"fork":true,"url":"https://api.github.com/repos/jordanramstad/scout","forks_url":"https://api.github.com/repos/jordanramstad/scout/forks","keys_url":"https://api.github.com/repos/jordanramstad/scout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jordanramstad/scout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jordanramstad/scout/teams","hooks_url":"https://api.github.com/repos/jordanramstad/scout/hooks","issue_events_url":"https://api.github.com/repos/jordanramstad/scout/issues/events{/number}","events_url":"https://api.github.com/repos/jordanramstad/scout/events","assignees_url":"https://api.github.com/repos/jordanramstad/scout/assignees{/user}","branches_url":"https://api.github.com/repos/jordanramstad/scout/branches{/branch}","tags_url":"https://api.github.com/repos/jordanramstad/scout/tags","blobs_url":"https://api.github.com/repos/jordanramstad/scout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jordanramstad/scout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jordanramstad/scout/git/refs{/sha}","trees_url":"https://api.github.com/repos/jordanramstad/scout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jordanramstad/scout/statuses/{sha}","languages_url":"https://api.github.com/repos/jordanramstad/scout/languages","stargazers_url":"https://api.github.com/repos/jordanramstad/scout/stargazers","contributors_url":"https://api.github.com/repos/jordanramstad/scout/contributors","subscribers_url":"https://api.github.com/repos/jordanramstad/scout/subscribers","subscription_url":"https://api.github.com/repos/jordanramstad/scout/subscription","commits_url":"https://api.github.com/repos/jordanramstad/scout/commits{/sha}","git_commits_url":"https://api.github.com/repos/jordanramstad/scout/git/commits{/sha}","comments_url":"https://api.github.com/repos/jordanramstad/scout/comments{/number}","issue_comment_url":"https://api.github.com/repos/jordanramstad/scout/issues/comments{/number}","contents_url":"https://api.github.com/repos/jordanramstad/scout/contents/{+path}","compare_url":"https://api.github.com/repos/jordanramstad/scout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jordanramstad/scout/merges","archive_url":"https://api.github.com/repos/jordanramstad/scout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jordanramstad/scout/downloads","issues_url":"https://api.github.com/repos/jordanramstad/scout/issues{/number}","pulls_url":"https://api.github.com/repos/jordanramstad/scout/pulls{/number}","milestones_url":"https://api.github.com/repos/jordanramstad/scout/milestones{/number}","notifications_url":"https://api.github.com/repos/jordanramstad/scout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jordanramstad/scout/labels{/name}","releases_url":"https://api.github.com/repos/jordanramstad/scout/releases{/id}","deployments_url":"https://api.github.com/repos/jordanramstad/scout/deployments","created_at":"2016-10-24T18:37:03Z","updated_at":"2016-10-24T18:37:04Z","pushed_at":"2016-10-24T18:38:22Z","git_url":"git://github.com/jordanramstad/scout.git","ssh_url":"git@github.com:jordanramstad/scout.git","clone_url":"https://github.com/jordanramstad/scout.git","svn_url":"https://github.com/jordanramstad/scout","homepage":null,"size":95,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"laravel:master","ref":"master","sha":"b6c3107c4dd53f9f79f899b688c971fcd53133cf","user":{"login":"laravel","id":958072,"avatar_url":"https://avatars.githubusercontent.com/u/958072?v=3","gravatar_id":"","url":"https://api.github.com/users/laravel","html_url":"https://github.com/laravel","followers_url":"https://api.github.com/users/laravel/followers","following_url":"https://api.github.com/users/laravel/following{/other_user}","gists_url":"https://api.github.com/users/laravel/gists{/gist_id}","starred_url":"https://api.github.com/users/laravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laravel/subscriptions","organizations_url":"https://api.github.com/users/laravel/orgs","repos_url":"https://api.github.com/users/laravel/repos","events_url":"https://api.github.com/users/laravel/events{/privacy}","received_events_url":"https://api.github.com/users/laravel/received_events","type":"Organization","site_admin":false},"repo":{"id":62261287,"name":"scout","full_name":"laravel/scout","owner":{"login":"laravel","id":958072,"avatar_url":"https://avatars.githubusercontent.com/u/958072?v=3","gravatar_id":"","url":"https://api.github.com/users/laravel","html_url":"https://github.com/laravel","followers_url":"https://api.github.com/users/laravel/followers","following_url":"https://api.github.com/users/laravel/following{/other_user}","gists_url":"https://api.github.com/users/laravel/gists{/gist_id}","starred_url":"https://api.github.com/users/laravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laravel/subscriptions","organizations_url":"https://api.github.com/users/laravel/orgs","repos_url":"https://api.github.com/users/laravel/repos","events_url":"https://api.github.com/users/laravel/events{/privacy}","received_events_url":"https://api.github.com/users/laravel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/laravel/scout","description":null,"fork":false,"url":"https://api.github.com/repos/laravel/scout","forks_url":"https://api.github.com/repos/laravel/scout/forks","keys_url":"https://api.github.com/repos/laravel/scout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laravel/scout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laravel/scout/teams","hooks_url":"https://api.github.com/repos/laravel/scout/hooks","issue_events_url":"https://api.github.com/repos/laravel/scout/issues/events{/number}","events_url":"https://api.github.com/repos/laravel/scout/events","assignees_url":"https://api.github.com/repos/laravel/scout/assignees{/user}","branches_url":"https://api.github.com/repos/laravel/scout/branches{/branch}","tags_url":"https://api.github.com/repos/laravel/scout/tags","blobs_url":"https://api.github.com/repos/laravel/scout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laravel/scout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laravel/scout/git/refs{/sha}","trees_url":"https://api.github.com/repos/laravel/scout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laravel/scout/statuses/{sha}","languages_url":"https://api.github.com/repos/laravel/scout/languages","stargazers_url":"https://api.github.com/repos/laravel/scout/stargazers","contributors_url":"https://api.github.com/repos/laravel/scout/contributors","subscribers_url":"https://api.github.com/repos/laravel/scout/subscribers","subscription_url":"https://api.github.com/repos/laravel/scout/subscription","commits_url":"https://api.github.com/repos/laravel/scout/commits{/sha}","git_commits_url":"https://api.github.com/repos/laravel/scout/git/commits{/sha}","comments_url":"https://api.github.com/repos/laravel/scout/comments{/number}","issue_comment_url":"https://api.github.com/repos/laravel/scout/issues/comments{/number}","contents_url":"https://api.github.com/repos/laravel/scout/contents/{+path}","compare_url":"https://api.github.com/repos/laravel/scout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laravel/scout/merges","archive_url":"https://api.github.com/repos/laravel/scout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laravel/scout/downloads","issues_url":"https://api.github.com/repos/laravel/scout/issues{/number}","pulls_url":"https://api.github.com/repos/laravel/scout/pulls{/number}","milestones_url":"https://api.github.com/repos/laravel/scout/milestones{/number}","notifications_url":"https://api.github.com/repos/laravel/scout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laravel/scout/labels{/name}","releases_url":"https://api.github.com/repos/laravel/scout/releases{/id}","deployments_url":"https://api.github.com/repos/laravel/scout/deployments","created_at":"2016-06-29T22:11:40Z","updated_at":"2016-10-24T10:31:23Z","pushed_at":"2016-10-24T18:54:45Z","git_url":"git://github.com/laravel/scout.git","ssh_url":"git@github.com:laravel/scout.git","clone_url":"https://github.com/laravel/scout.git","svn_url":"https://github.com/laravel/scout","homepage":null,"size":172,"stargazers_count":240,"watchers_count":240,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":65,"mirror_url":null,"open_issues_count":28,"forks":65,"open_issues":28,"watchers":240,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/laravel/scout/pulls/116"},"html":{"href":"https://github.com/laravel/scout/pull/116"},"issue":{"href":"https://api.github.com/repos/laravel/scout/issues/116"},"comments":{"href":"https://api.github.com/repos/laravel/scout/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/laravel/scout/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/laravel/scout/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/laravel/scout/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/laravel/scout/statuses/83aca950dfd45deab9b390969687bc49ef0b027c"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":1,"review_comments":0,"commits":1,"additions":5,"deletions":1,"changed_files":1}}
{"actor":{"display_login":"taylorotwell"}}