use Like with multiple columns

3

I am looking in one form or another for data in my columns

$search = Notificaciones::
                where('canal', 'LIKE', '%'.$canal.'%')
                ->where('region','LIKE', '%'.$region.'%')
                ->where('cadena','LIKE', '%'.$cadena.'%')
                ->get();

This is working, my problem is that the columns are string and the data is divided by comma

  

example format

sur,centro,occidente

When I try to use for example SQL>..LIKE .. (sur,centro) it does not show me anything even though in my table there is only centro .

Someone knows how, even though I sent him a complete string, look in it as in the example, that I am sending a string separated by commas, but only one of those values is found in my column.

    
asked by DoubleM 18.12.2018 в 23:19
source

1 answer

1

In the laravel the where function refers to the clause and of sql
for or you must use orWhere Example:

$search = Notificaciones:: where('canal', 'LIKE', '%'.$canal.'%')           
                        ->orWhere('region','LIKE', '%'.$region.'%')      
                        ->orWhere('cadena','LIKE', '%'.$cadena.'%')        
                        ->get();
    
answered by 18.12.2018 в 23:27