You will have to either join all tables before searching, or execute the same search for each and merge the results.
Unfortunately having seperate tables for each will cause you this type of extra redundant work
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Working on a search functionality on Laravel App(Blog/Posts). There are multiple types of posts (each having a separate table in the database) Like Business posts, Social Life posts etc..
Below is the search function on SearchController
class SearchController extends Controller
{
public function search(Request $request, $query = null)
{
if($query == null)
return redirect()->route('home');
$search = Business::where([['title','like','%'.$query.'%'],['status','=',1]])
->orWhere([['description','like','%'.$query.'%'],['status','=',1]])
->paginate(10);
return view('front.search',[
'results' => $search,
'query' => $query
]);
}
So basically my question is how to add Social Life Post's table and some other tables also?
Please or to participate in this conversation.