This is continuity form the previous post https://dev.to/nasrulhazim/laravel-scout-create-a-single-api-endpoint-for-searching-purpose-only-1bj4. I was asked if it is possible, if we create a Global Search?

The route: get('/search', function (Request $request) { abort_if( empty($request->search), 404, 'Please provide search keyword' ); return search($request); }); Enter fullscreen mode And the helper: type); $keyword = $request->search; $paginate = $request->query('paginate', false); $types = empty($type)?

in_array(Searchable::class, class_uses_recursive($type->value))); $class = $type->value; $query = $class::search($keyword); $data[$type->label] = $paginate ?
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners