Laravel filter a value in all columns

eloquent, laravel, php

Solution

Most databases do not support searching all columns simultaneously. I'm afraid you'll likely have to chain all of the columns together:

$books = Book::where('book_name', 'LIKE', '%' . $input . '%')
    ->orWhere('another_column', 'LIKE', '%' . $input . '%')
    // etc
    ->get();

Problem

``` public function getBooks($input) { $books= Book::where('book_name', 'LIKE', '%' . $input . '%')->get(); return Response::json($books); } ``` I know how to filter a column by a given value. But how do I filter ALL columns by a given value. For example, I have a column called 'category' where user should be able to use the same search bar to filter the category. Something like: ``` $books = Book::where('all_columns', 'LIKE', '%' . $input . '%')->get(); ``` Thanks!

Original source