Hi, I would like to search not only by query but also by another variable. So I have query and status. I can add it in the search input and generate right url (like ?q=sometning&status=3). It returns right query but all statuses. Can you help me?
Code in my plugin.php:
public function boot() { \Event::listen('offline.sitesearch.query', function ($query) {
// The controller is used to generate page URLs.
$controller = \Cms\Classes\Controller::getController() ?? new \Cms\Classes\Controller();
if (isset($status)) {
// Search your plugin's contents
$items = \Alava\NameOfPlugin\Models\Item
::where('title', 'like', "%${query}%")
->orWhere('description', 'like', "%${query}%")
->where('status', 'like', "%${status}%")
->get();
} else {
// Search your plugin's contents
$items = \Alava\NameOfPlugin\Models\Item
::where('title', 'like', "%${query}%")
->orWhere('description', 'like', "%${query}%")
->get();
}; ....
Last updated