I'm looking for a way to loop through all my database tables in Laravel in order to add a search functionality to my website.
I guess there should be a way to do this without hardcoding all the table names.
You can do this:
$tables = DB::select("select table_name from information_schema.tables where table_schema='your_database_name'");
Just change your_database_name to your own value. Then you can use the Laravel helper function, array_pluck, to get an array of the table_name values.
array_pluck($tables, 'table_name')