I
I
Igor Tarasov2020-09-12 20:34:34
Laravel
Igor Tarasov, 2020-09-12 20:34:34

Why doesn't the where method of Laravel collections support all PHP statements?

$collection = collect([
['product' => '1', 'price' => 1],
['product' => '2', 'price' => 2],
['product' => '3 ', 'price' => 3],

]);
print $collection->where('price', '&', 1)->pluck('product')->implode(', ');

Prints 1 instead of 1.3.

It would be logical to have all the operators here https://github.com/laravel/framework/blob/c6cf3813...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2020-09-12
@Sanasol

https://laravel.com/docs/master/collections#method...

U
UksusoFF, 2020-09-12
@UksusoFF

Because there are sql statements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question