Created
December 19, 2018 12:39
-
-
Save nunomaduro/fc3751807c7bcae7f067e072b1d15397 to your computer and use it in GitHub Desktop.
Searching aggregators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$models = App\Search\News::search('Star Trek')->get(); | |
echo get_class($models[0]); // "App\Article" | |
echo get_class($models[1]); // "App\Comment" | |
$results = App\Search\News::search('Star Trek')->raw(); | |
/* | |
{ | |
"hits":[ | |
{ | |
"id":1, | |
"title": "Article title", | |
"slug": "article-title", | |
"content": "Article content", | |
"objectID":"App\\Article::1", | |
... | |
}, | |
{ | |
"id": 1, | |
"content": "Comment content", | |
"objectID": "App\\Comment::1", | |
... | |
}, | |
], | |
... | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment