Laravel Advanced - Make Dedicated Class For Model Collection

preview_player
Показать описание
Let's be friends:

Github Repo:
Please read the readme to access the code for the specific video.

In this video, I have discussed how to make a dedicated collection class. Using a dedicated collection class will make the controller cleaner and also will help to reduce the duplicate code.

Laravel 8 Advanced - Has One Relationship

Laravel 8 Advanced - Has Many Relationship

Laravel 8 Advanced - Many to Many Relationship

Laravel 8 Advanced - Has One Through Relationship

Laravel 8 Advanced - Has Many Through Relationship

Laravel 8 Advanced - Polymorphic Relationship
Рекомендации по теме
Комментарии
Автор

After collection can i make lazy eager loading?, thank before has created great tutorial ever seen

kevariable
Автор

Isn't this slower than performing DB queries for each status? Rather than getting all data and performing filter.
I would rather go with scopes.

mirkodzudzar
Автор

Maybe better next refactor... collections...
Sugestion - only one function, no three...
public function status($status) {
return $this->filter(function ($product) use ($status) {
return $product->status === $status ;
});
}
and call... $products->status('Draft')

JACKoPL