B
B
BonBon Slick2017-10-05 13:38:48
Laravel
BonBon Slick, 2017-10-05 13:38:48

Why doesn't the LIKE operator work when fetching from a collection?

We have a collection of objects, they have "slug" => "slug-ru"

$collection->where('slug', 'LIKE', 'slug')->first() // работает
$collection->where('slug', 'LIKE', 'slug%')->first() // нет
$collection->where('slug', 'LIKE', '%slug%')->first() // нет

Of course, you can also use ->whereIn( https://laravel.com/docs/5.4/collections#method-where but this is not the case.
Please tell me what I missed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-10-05
@BonBonSlick

like database function
collection is just an array, so it can't do that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question