Tuesday, March 14, 2017

Eloquent query to LIKE query

:) In my 40-lines query (Eloquent, Laravel), I have this part:

->orWhere(function ($query) {
    $query
        ->where('questions.category', '=', Auth::user()->category);
})

This works OK, but I want to make it like: '%questions.category%' LIKE Auth::user()->category. I've read I should use CONCAT, but after several tries, I only got a lot of errors. What's the best way to do this? :)



via Diamond Fox

Advertisement