Laravel Collection Chains vs Arrays: Simple Demo

preview_player
Показать описание
One simple demo of how to perform a few operations with array operations, array methods, or Laravel collections. Which one would you pick?

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

Excellent approach would love to use in Laravel, but as often I'm working on different languages and frameworks i prefer classic way for welcoming juniors as well to take over for the changes etc

pilotcoding
Автор

When chaining more than one method, I recommend transforming it into a LazyCollection first to reduce time complexity (*Model::query()->cursor()* for DB, *collect()->lazy()* for the rest)

Voltra_
Автор

I came from JS world so it's really worth learning Collection :D

szymonpszczoka
Автор

Great example, not so different from Stream API and related methods (map, filter, collect) we see in Java

phil_
Автор

In my humble opinion prefer the pure php method for simple tasks 'cause any call to Laravel's commands implies more code to be executed for the server. I'm most for a compromise between code easy to read and performance. But, another time, this is simply my humble opinion.

Buscalia
Автор

as someone who also works with javascript, I am used to array method chaining.

soniablanche
Автор

In this instance this looks less readable than the original for each. I love using collections and chaining with maps etc but I think in this example the regular php method would be preferable.

joshedwards
Автор

hey;
thanks for video ıt's a helpful video but I have a question how to define two dimensional array? ( $arr[][] ) thanks for answer

burakozcan
Автор

in therms of performances which one is the best? With collection it's more elegant and readable, but sounds too many loops on it, isnt it?

giacomogaravaglia
Автор

I prefer to use the collection in Laravel.

yashpatel
Автор

PLS make full course about Laravel collection

unitaxi
Автор

I believe sometime Laravel collection is quite slow than array. E.g: Collection filters..

sirnt
Автор

Como hago para que en un $data = collect()->put('name', 'jesus' ); pueda hacer $data->name;

TheSnower
Автор

Whenever i see the collection methods in laravel docs i always think why php array methods are not as simple as this.

juniordev
Автор

How to make a comment reply system in livewire with recursion? This concept is seriously so hard to understand!

darkestbrush