Multi-page search

Here is the code I use to search on 2 pages,
I would like to know if it is correct?
(At first sight it works very well)

<?php

return function($site, $pages, $page) {

	$page1 = page('themes')->children();
	$page2 = page('authors')->children();
	$newPage = $page1->merge($page2);

	$query   = get('q');
	$results = $newPage->search($query, 'title');

	$results = $results->paginate(20);

	return compact('query', 'results', 'pagination');

};

Thank you.

All fine… (and some more chars):slightly_smiling_face:

Thank you :grinning:
I did not find a simpler way.

An alternative would be using the pages helper like this:

$collection = pages([page('projects')->children(), page('blog')->children()]);
1 Like

Great thank you ! :muscle:t2: