Laravel Services and Repositories: 3 Example Projects

preview_player
Показать описание
Service classes in Laravel is one of the most misunderstood concepts because developers use them in a very different way. Let's take a look at three examples.

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

Services = Business Logic stuff
Repositories = Database related stuff

Controllers interact with Services.
Services interact with Repositories.
Repositories interact with a Model and its relational Models if neccesary (one-to-many, many-to-many, etc).

Repositories should not access other Repositories, that kind of logic should be done in a Service.

robertoflores
Автор

Thanks for mentioning my code in 2nd example. And it's not a fully done project yet. I am still doing that project.

cultureofnepal
Автор

I wish this video came in a couple of weeks earlier. I received a project following that same pattern and it was a little bit hard to understand at first.
It was really nice to see your explanation and now I’m more confident in the changes I’m making to this project

gustavoaeidt
Автор

I remember to avoid TypeHint REQUEST in service via Dependency Injection. Instead just pass Request Array.
It is useful in TESTs also.
Respect from Pakistan 🇵🇰

nabeelyousafpasha
Автор

Man your contents are getting richer. 😀

SowrenSen
Автор

Awesome stuff, I always get a lot of stuff from your videos.

popplestones
Автор

Really interesting and useful, since Service/Repository is a common pattern also used in other languages, for instance in Java, to build more structured modules (and to make controllers or jobs or whatever much shorter!).
It’s a very important topic.

phil_
Автор

Thanks a lot for sharing examples regarding Services and Repositories, I hope you keep posting more of it because it's really helpful.
The only thing that seems off to me is the idea of passing the request to the service. I've seen it in cases even reaching to the repository and I don't believe it's a good practice. It makes quite hard to reuse these methods since you don't know which fields the method uses unless you read it thoroughly

JoseVasquez-vyyf
Автор

You are really superman ❤️🇸🇩 thank you For the grateful lite tutorials. u are helpful please go on don't stop

MegaOsama
Автор

Please make a video about PORTO pattern (implemented on apiato project) thanks! Most used architectual patterns for large laravel projects

joaoprizal
Автор

I am recently learning different design pattern of php. I would be glad to know different design patterns that can be used with laravel beside services.

jannatulnayeem
Автор

@3:27 IMO policy inside the StoreBookingRequest would be better to implement the same functionality (availabilityCheck)

atatopatato
Автор

When dealing with DB transaction, It should be done in controller or in a service? The service should be throw exceptions and the controller catch it?

risoledoce
Автор

You mentioned at the end ”To off load your controllers and make controllers shorter” does it mean better performance in controllers? And thats why we use Service? Or is it only for structure and readability?

balle
Автор

Can you make a vid that explain how to structure your payment services (Paypal, Stripe, local banks ..etc) and use it with a clean code?

mohamed-haj
Автор

First of all, thank you so much for all your work! What are your thoughts on using Jobs for all CRUD (except Read part) operations?

dApoTB
Автор

Thank u for the video, Is this good habit making two new instance of a class as seen as 3:15 second of video with Booking class?.May it perform for speed or cpu ?.

MrKederli
Автор

Wonder if there are any tests for those services in the examples and if services that have tests are written "better" than the ones that don't have tests.

alexrusin
Автор

This approach would be nice with Domain Driven Design

joshbarros
Автор

Hello Dear! Please tell me which framework vue or livewire is good to use with laravel. Should we use vue if our site is too much reactive or livewire would be a good choice in case site is too much reactive.

uzairsharif