V
V
Vlad Saenko2020-07-29 15:59:12
Laravel
Vlad Saenko, 2020-07-29 15:59:12

How to use more than one method in controller?


public function search(Request $request){
$search_products = Product::where('title', 'LIKE', '%' . $request->get('search') . '%' )->get();


There is such a controller (for "live search"), you need to search not only in 'title', but also in 'description'.
This option doesn't work:

where('title', 'LIKE', '%' . $request->get('search') . '%' )||where('title', 'LIKE', '%' . $request->get('search') .'%' )->get()

since it returns a boolean value.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-07-29
@Domovik93

https://laravel.com/docs/7.x/queries#where-clauses clause orWhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question