Search via API


I registered a custom API endpoint to get search results from Statamic. The search works (I copied parts of it from the control panel SearchController).

But instead of returning the queried json object directly, I would like to return it as an EntryResource (with pagination data) like the Content API does for entries:

  "data": [
      "title": "My First Day"
  "links": {...},
  "meta": {...}

My controller looks like this:

class SearchController extends ApiController

        public function __invoke(Request $request)

                return Search::index()
                    ->filter(function ($item) {
                        return $item->published();
                    ->map(function ($item) {
                        return $item->toAugmentedCollection()->withShallowNesting();

How can I translate the output of Search into an EntryResource?


Answered by Dominik Radl!
>>>>>>> Answered <<<<<<<
2 Replies