Тёмный

Laravel Services and Repositories: 3 Example Projects 

Laravel Daily
Подписаться 145 тыс.
Просмотров 39 тыс.
50% 1

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 64   
@robertoflores2078
@robertoflores2078 3 года назад
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.
@TIAGO543211
@TIAGO543211 2 года назад
so i may not call a repository in a controller? would be right: controller -> service -> repo?
@cultureofnepal2024
@cultureofnepal2024 3 года назад
Thanks for mentioning my code in 2nd example. And it's not a fully done project yet. I am still doing that project.
@gustavoaeidt
@gustavoaeidt 3 года назад
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
@nabeelyousafpasha
@nabeelyousafpasha 3 года назад
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 🇵🇰
@MaizerGomes
@MaizerGomes 3 года назад
Learned that the hard way.
@Jurigag
@Jurigag 3 года назад
What i personally prefer that in service you have specified methods iwht actual parameters you want to call. So instead of passing request or some general array you just provide like int, strings etc stuff and other arrays, like only what's needed for a method.
@SowrenSen
@SowrenSen 3 года назад
Man your contents are getting richer. 😀
@phil86_
@phil86_ 3 года назад
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.
@JoseVasquez-vy8yf
@JoseVasquez-vy8yf 3 года назад
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
@anmaner4822
@anmaner4822 3 года назад
The author of the video is fool. This kills the whole point of using the services/usecases. We will not be able to call such service from the API, console application or queue system.
@thamibn
@thamibn 3 года назад
@@anmaner4822 he did a video about not using request on services, so don't call him a fool, cause he did not even say it was good in this video.
@anmaner4822
@anmaner4822 3 года назад
​@@thamibn Are you joking? What's the matter what was in the other videos? In this video he uses function auth()->user(). And now the question, what if he calls this service from console? Everything will break, and how i said above this kills the whole point of using services.
@thamibn
@thamibn 3 года назад
@@anmaner4822 he did not use it his not the one who wrote the code, basically in this video he was showing us how services worka or helps with code readability, he was not by any means trying to fix the code inside those services, if you can check there are many wrong things on those services he demonstrated but the video was not about fixing them instead on how to use them Nd how they help. On the other video he clearly thought how to write service classes, and he not to use $request since it won't be accessible when the service is being called on tests,commands etc... I do agree that the service classes used on the video where poorly coded, my point is don't call him fool cause is not his code and he was not fixing them service classes on this video.
@popplestones886
@popplestones886 3 года назад
Awesome stuff, I always get a lot of stuff from your videos.
@ujjal147
@ujjal147 3 года назад
I used a Service pattern discussed by Povilas in one of the projects I work on, it was really helpful! Needed to duplicate some functionality on different pages.
@MegaOsama99
@MegaOsama99 3 года назад
You are really superman ❤️🇸🇩 thank you For the grateful lite tutorials. u are helpful please go on don't stop
@joaoprizal8936
@joaoprizal8936 3 года назад
Please make a video about PORTO pattern (implemented on apiato project) thanks! Most used architectual patterns for large laravel projects
@balle19941
@balle19941 3 года назад
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?
@LaravelDaily
@LaravelDaily 3 года назад
It's for structure and readability
@nevesparrottino4394
@nevesparrottino4394 3 года назад
Thank you for the feedback 👍
@risoledoce
@risoledoce 3 года назад
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?
@jannatulnayeem7289
@jannatulnayeem7289 3 года назад
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.
@LaravelDaily
@LaravelDaily 3 года назад
I discuss a lot of them in my course: laraveldaily.teachable.com/p/how-to-structure-laravel-project
@MrKederli
@MrKederli 3 года назад
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 ?.
@alexrusin
@alexrusin 3 года назад
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.
@dApoTB
@dApoTB 3 года назад
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?
@LaravelDaily
@LaravelDaily 3 года назад
I quite like Jobs, but not for CRUD operations themselves, but rather AFTER CRUD operation. So, like User::create() and then dispatch a Job to send an email.
@ruslanvoroshchukowlookitlt245
@ruslanvoroshchukowlookitlt245 3 года назад
Hi Povilas, thanks for the great video with Laravel services patterns reviewal! Just wanted to ask you, have you some preferable PHP and Laravel packages very useful for building API for Laravel based SPA? I'm most interested with the secure authentication/authorisation, flexible roles management, message driven services, multi-tenancy. Probably some of them are already included in the scope of QuickAdminPanel stack. Could you please make a quick review based on your experience, or share some practical advices? Thanks a lot and please don't stop posting new streams! Cheers.
@LaravelDaily
@LaravelDaily 3 года назад
Not sure if there are "best practices", I guess I would list Laravel Sanctum and Spatie Permissions.
@uzairsharif7568
@uzairsharif7568 3 года назад
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.
@atatopatato
@atatopatato 3 года назад
@3:27 IMO policy inside the StoreBookingRequest would be better to implement the same functionality (availabilityCheck)
@jasonennis4905
@jasonennis4905 3 года назад
Respect from 🇯🇲
@Diego-eb9we
@Diego-eb9we 2 года назад
Could SpliCostService be a Trait as well?
@mohamed-haj
@mohamed-haj 3 года назад
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?
@LaravelDaily
@LaravelDaily 3 года назад
That would be a full 5-hour course. Maybe someday I will have enough time for it.
@pvaitonis
@pvaitonis 3 года назад
Super! Very useful video.
@shahidjutt5656
@shahidjutt5656 3 года назад
hello sir .i install jetstream and then i want to extend layouts.app in another file but layouts.app file contain $header and $slot ,so it give $header is not defined or same for $slot.how can then i extend layout.app. im using laravel 8 with jetstream livewire
@jjhehe5747
@jjhehe5747 3 года назад
Very informative!
@kevinpallado9638
@kevinpallado9638 3 года назад
Wow this is what I am waiting for
@joshbarros1995
@joshbarros1995 3 года назад
This approach would be nice with Domain Driven Design
@al-aminhamadi9451
@al-aminhamadi9451 3 года назад
Nice stuff
@angelogrieco
@angelogrieco 3 года назад
So this repository pattern has nothing to do with Symfony repositories?
@adebajooluwaseyi2124
@adebajooluwaseyi2124 3 года назад
😂😂😂
@angelogrieco
@angelogrieco 3 года назад
@@adebajooluwaseyi2124 what's funny?
@guillermocava3568
@guillermocava3568 3 года назад
Services vs Actions, or is the pattern essentially the same?
@LaravelDaily
@LaravelDaily 3 года назад
I will have a separate video on Actions, in a few days.
@1mr4n4li
@1mr4n4li 3 года назад
You guys have good team why don't you make an ecommerce platform and sale its components just like other doing etc opencart? I don't see any good ecommerce platform in laravel with good documentations. You can easily build opencart like with your capabilities
@LaravelDaily
@LaravelDaily 3 года назад
It would cost too much. And personally, I don't believe in financial success, as there are already ecommerce platforms on Laravel, but none of them seemed to get traction.
@manishchourasiya3988
@manishchourasiya3988 3 года назад
hi sir, I had learn a lot from your videos, and even started exploring many concept. sir can you give me way to contact you. need your consultants .
@abdulbasitsalah2918
@abdulbasitsalah2918 3 года назад
how to remove dublicate value from an array while using foreach directive loop in laravel?
@LaravelDaily
@LaravelDaily 3 года назад
Try converting to collection and use unique() laravel.com/docs/8.x/collections#method-unique
@abdulbasitsalah2918
@abdulbasitsalah2918 3 года назад
@@LaravelDaily thanks you sir, thats working
@amanikafonogo9695
@amanikafonogo9695 3 года назад
Respect from 🇹🇿Tz
@danorex9100
@danorex9100 3 года назад
How can I switch between Paypal / Card Payment / Anything if the binding is with the service provider, if the user has a choice when paying.
@LaravelDaily
@LaravelDaily 3 года назад
Yes, valid question, that example code wouldn't work for your scenario.
@cultureofnepal2024
@cultureofnepal2024 3 года назад
You could pass the payment method in request and check that payment in service provider and bind the class according to request payment variable.
@raimonds.L
@raimonds.L 3 года назад
Please review DataTables and why do we need it :)
@LaravelDaily
@LaravelDaily 3 года назад
I have a full separate course: laraveldaily.teachable.com/p/datatables-in-laravel Also, search the channel for "datatables", you will find quite a lot of videos.
@ahmadrio
@ahmadrio 3 года назад
wow terima kasih
@safara_umarov
@safara_umarov 3 года назад
Please make laravel from scratch for beginners 🙏🙏🙏🙏🙏
@LaravelDaily
@LaravelDaily 3 года назад
Done: laraveldaily.teachable.com/p/laravel-for-beginners-your-first-project
@popelyshyn
@popelyshyn 3 года назад
Respect from Ukraine 🇺🇦
@abhishekpakhare7682
@abhishekpakhare7682 3 года назад
first view first like
Далее
Laravel Code Review: Why NOT Use Repository Pattern?
14:21
Laravel Service Providers: All You Need to Know
13:13
Laravel: Repository Pattern in practice
27:13
Просмотров 12 тыс.
All Rust features explained
21:30
Просмотров 314 тыс.
Two Things Laravel Services Should NOT Do
8:20
Просмотров 22 тыс.