Тёмный
No video :(

Laravel 6 Advanced - e7 - Repository Pattern 

Coder's Tape
Подписаться 61 тыс.
Просмотров 104 тыс.
50% 1

The Repository Pattern is a common refactor that you may encounter in large Laravel applications. While it is not ideal for small to medium projects, it's a perfect solution for those applications that need an abstraction of the data layer.
For the best experience, follow along in our interactive school at www.coderstape...
DigitalOcean Referral
m.do.co/c/7dce...
Hit us up on Twitter with any questions or comments @codertape ( / coderstape )
About This Course
Ready to level up your Laravel skills? This series is for you, follow along as we uncover the advanced Laravel features that actually make Laravel the most popular php framework. We'll have lot of tips and tricks along the way. Are you ready?

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

 

23 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 224   
@morleytechtv7749
@morleytechtv7749 5 лет назад
this is crazy dude. hope you have good health to create more videos. I learn a lot from your videos.
@andynguyen8124
@andynguyen8124 4 года назад
Dude, that map->format(); is genius, Wow Also I've never know that we can ->diffForHumans() from carbon, thanks so much
@victorwillhuber
@victorwillhuber 2 года назад
Man, I watch A LOT of educational videos on coding (php, js, laravel, vue) and you are the best.
@abunooh9005
@abunooh9005 5 лет назад
I never comment on anything, but this series is just too helpful. You are my new Laravel teacher. Keep it up and thank you very much. You are awesome!
@phentube2345
@phentube2345 4 года назад
where were you, finally I found someone that knows pure implementation and architecture.
@kasmanialisaad
@kasmanialisaad 5 лет назад
These advanced series are very helpful. Thanks!
@CodersTape
@CodersTape 5 лет назад
Happy to hear that. More advanced topics are much more time consuming in preparation leading up to recording the lesson.
@julienSibille
@julienSibille 5 лет назад
@@CodersTape Thanks for your work Victor, what about another Udemy course applying those advanced concept ?
@priteshshinde6779
@priteshshinde6779 4 года назад
We understand that it is more time consuming, but you know you've got 1 more subscriber just now (me). I'm sure you'll get alot more subscribers until this series end, but please make more videos.
@CircuitMoe
@CircuitMoe 3 года назад
your practical explanation is phenomenal. Keep up the good work please, people like us depend on you.
@mohammedmahmoud1182
@mohammedmahmoud1182 3 года назад
The best coding channel out there. I hope you post more videos as you used to.
@wanamra899
@wanamra899 2 года назад
I never not like every single video i watched from this dude. Thanks a lot bro.
@josebriceno7578
@josebriceno7578 Год назад
Crazy good content, thanks a lot for posting this. The quality of this video is unreal. God bless you man!!
@AirMalta89
@AirMalta89 5 лет назад
This course is amazing. Not the usual blah-blah most good laravel devs already know. But really insightful, solving real-life problems where you were thinking as a dev, there should be a nicer solution for this!
@ammaralhomyqani9079
@ammaralhomyqani9079 3 года назад
Thank u so much, we need people like you in this world
@Yuri-sf5mx
@Yuri-sf5mx 5 лет назад
Watched this video to fresh up my memory on repositories and honestly you make great videos and your explanation is to the point. Love your style. On the subject though i do find that the only reason you should use repositories is when you expect to swap out your database for something else. Other than that i stick with model query scopes for the repetitive query's (powerfull for their chainability) and use resources to format them. Even on very large projects. You could still use repositories in combination with these, but as said, the only added value is data driver independency. *Edit* Looks like this has been said a few times. Either way, it boils down to project requirements and personal favor. There is no "right" way.
@CodersTape
@CodersTape 5 лет назад
Absolutely.
@MarcoAZeballosS
@MarcoAZeballosS 4 года назад
It's the first time I get to clearly understand Repositories. I cannot pass to the next video without congratulating you and thanking you for such amazing video/explanation. 👏🏼👏🏼👏🏼
@CodersTape
@CodersTape 4 года назад
Thanks
@Wane-maxx
@Wane-maxx 8 месяцев назад
well, you are still not, because repo pattern is not needed when using laravel
@ProgrammingwithPeter
@ProgrammingwithPeter 5 лет назад
Cool, unfortunately beginners take Repository as granted, glad that you pointed out that it is meant for larger apps!
@MustafaBirsoz
@MustafaBirsoz 3 года назад
I love your tone and the content here
@ahmadmayahi
@ahmadmayahi 3 года назад
The repository should only be used to reterive the data. It's a common mistake that some developers use repositories for storing/updating/deleting, but it’s not meant to be like that. If you need to store/update/delete then you have to have a persistent layer. I think Doctrine did the best implementaion of repositories.
@dr.adam.nielsen
@dr.adam.nielsen 3 года назад
In literature you find that the main purpose of repositories is to be a layer between your data mapping and the business logic. Its totally fine to store/update/delete date there. See stackoverflow.com/questions/57340681/should-we-save-update-models-in-repository-pattern
@Wane-maxx
@Wane-maxx 6 месяцев назад
So what are we supposed to use instead of repos?
@Stoney_Eagle
@Stoney_Eagle 5 лет назад
I will definitely implement the format function, I feel like I've been repeating myself a lot on database queries. Thanks!
@brunofunnie
@brunofunnie 2 года назад
Experiment Fractal
@yurabobrov6717
@yurabobrov6717 5 лет назад
If I could to press "Like" twice, I would do it! Awesome tutorial as always.
@utshabroy
@utshabroy 5 лет назад
Thanks you for this video. I learned a lot. However, I read some blog where the Repository is connected with the ServiceLayer. If I'm right then can you please make a video on how Repository and ServiceLayer works together on big projects. Thank you again 😊 you are the best Laravel tutor.
@nullpadshot
@nullpadshot 4 года назад
Collection()->map->formatCallback()? and you dont kidding? Freakin awesome! That save me at least 1000 rows of code! Awesome! Thank you so much!
@ssjuma
@ssjuma 4 года назад
Interface implementation was my best part, loved it!
@aristideherve5748
@aristideherve5748 5 лет назад
You are incredible ! I asked for a video on it in your last video and you did it. Everything is clear ans precise. God bless you!
@shaheerarain50
@shaheerarain50 3 года назад
I was smiling while watching your video and thinks how a person could be so good at ♥️ Thank you
@paolopalubs64
@paolopalubs64 5 лет назад
Very informative! I've been using using model repositories for a long time now, and this is a good tutorial for those who haven't tried it yet. This is useful specially when doing reports.
@MrAlaa3344
@MrAlaa3344 3 года назад
you're the best ever in explaining leravel
@fabianleon1744
@fabianleon1744 5 лет назад
Thank you very much for these videos 🙌. I have read many times about the repository pattern, but this is by far the best explanation I have found.
@milantarami
@milantarami 5 лет назад
Learning more advanced things in this advanced laravel series, out of the box :) .... Need a tutorial on Service Pattern implementation
@ahmadmayahi
@ahmadmayahi 3 года назад
12:19 You can avoid mixing transformers into repositories by using an external transformer. In this case, the fractal package would be amazing to use.
@KuroUsagi1010
@KuroUsagi1010 2 года назад
May I ask where they are going to be called when formatting? should it be on the controller? or on the repository?
@adaamgbede283
@adaamgbede283 3 года назад
Nice video. I really learn a lot. I wonder why people gave this a thumb down
@THEShAdOwHFV
@THEShAdOwHFV 6 месяцев назад
Min 21:00 For those that can't load the provider when registering it in app.php file (test the provider with dd("plainText")) You can do: php artisan config:clear php artisan clear-compiled composer dump-autoload If composer is failing, just delete the "dd("test")" in your provider
@xaeemsayyed1437
@xaeemsayyed1437 2 года назад
thanks for creating such amazing video , i really love the way u clear concept in depth .
@rahulshimpi8914
@rahulshimpi8914 5 лет назад
Great great video please make more advance video. You are really professional programmer.
@TUTORIALSUZ
@TUTORIALSUZ 4 года назад
Thank you, bro!!! You are awesome! I learnt everything I'm confused. Thank you for your lessons. Sincerely, Sanjarbek from Uzbekistan.
@ahmedhamza9277
@ahmedhamza9277 Год назад
that's greate, greate series, greate demonstrations and easy to understand, thanks man :))))
@ayazahamed8254
@ayazahamed8254 Год назад
Very well explained. Useful content.
@yuchenglong672
@yuchenglong672 4 года назад
I think for those who don't potentially change their projects databases, a cleaner way is to implement a eloquent based repository design pattern, that works specifically with laravel eloquent, and just so much cleaner and readable. For a large projects which may be deployed with different types of dbs, a middle layer like the repository interface design pattern is almost like a must go-to idea.
@mori181186
@mori181186 5 лет назад
This is why i love Laravel. Thanks for your good videos :)
@peymanGhaderkurehpaz
@peymanGhaderkurehpaz 4 года назад
awesome , can you make more videos like this ? implementing design patterns and advanced php and laravel technics are awesome . Thanks again
@serhiicho
@serhiicho Год назад
Quick note. You bind interfaces in register() method of the service provider
@sardinas3675
@sardinas3675 5 лет назад
This is fr**king awesome my friend! I hope that someday or in the future that you will create a video on SOLID pattern in laravel. Btw You are the best
@CodersTape
@CodersTape 5 лет назад
Thanks
@codewithtee
@codewithtee 3 года назад
@@CodersTape have you big man?
@Brianle180
@Brianle180 4 года назад
Just totally love all your tutorials. Keep it up.
@SunilparajuliKenshin
@SunilparajuliKenshin 4 года назад
This is the best quality content coding pattern
@dilipdev8699
@dilipdev8699 2 года назад
Really amazing!. What about next point after implementation the interface?. Even without the interface we can do the same things. Then what's the purpose of the interface here?.
@xdEdgarBest
@xdEdgarBest 5 лет назад
Your videos are simply the best, thank you
@oghenerukevwekofi7976
@oghenerukevwekofi7976 4 года назад
I think repositories are also beneficial for testing. When you have the data layer coded against an interface like this, it becomes easier to mock it while testing. Depending on your needs, I think you might want to be able to separate tests that will reach the database from tests that just see if your basic functionality is working or not.
@peymanGhaderkurehpaz
@peymanGhaderkurehpaz 5 лет назад
That was awesome , thanks , these Advanced video series are awesome .
@phoe7ix
@phoe7ix 4 года назад
An extremely useful lesson, thank you, Victor!
@mubashirali5687
@mubashirali5687 2 года назад
Great explanation about repository pattern :-)
@colonelvector
@colonelvector 4 года назад
Excellent explanation, grasped it immediately.
@maharagab5107
@maharagab5107 5 лет назад
Very helpful , I was waiting for it thank you so much, really appreciate all the valuable content you provided thanks again!
@anoopsankar7726
@anoopsankar7726 3 года назад
This is very useful. I learnt a lot. Thanks for the video.
@KistlakRajapakshaSevenNet
@KistlakRajapakshaSevenNet 4 года назад
100% Perfect !! Thank You very Much Bro !! :D
@tonviet712
@tonviet712 5 лет назад
This map->format() blow my mind. That’s incredible video. But I still have some confusions: I knew about this pattern, but still don’t understand why this is necessary. Does it put all of logic to get data from Model to Repository? What pros and cons when put all logic in Model instead of Repository? Thank in advance
@CodersTape
@CodersTape 5 лет назад
truthfully, I think it's a design decision more than anything. I particularly like heavy models and don't use repository patterns. One use case I can understand is when you are managing several different data sources and need to access them equally. Example might be news, let's pretend you are receiving news feeds, one is coming as an RSS feed, another is content written in-house and maybe 3-4 different sources. Repository will make the consolidation easier because they can be treated differently but accessed with the same API.
@tonviet712
@tonviet712 5 лет назад
Coder's Tape You are my new fav teacher. Great explanation !!! Thanksssss
@CodersTape
@CodersTape 5 лет назад
@@tonviet712 Thanks!
@TolvirRam
@TolvirRam 3 года назад
Thanks a lot. Finally I understand repositories :))
@carlosmillanmazzucco1766
@carlosmillanmazzucco1766 3 года назад
My god dude! thanks so much!! this video clarified me a lot of things. Love ur channel and content! cheers
@mohd.aadilads3889
@mohd.aadilads3889 11 месяцев назад
Very good explanation 🎉🎉
@limuelmendoza5356
@limuelmendoza5356 3 года назад
i hope i've seen your channel before my project... life shouldve been way easier
@hassanalthaf8561
@hassanalthaf8561 4 года назад
I would honestly keep that format method within the Repository, as when you're writing a new concrete implementation of the repository, you might miss out on that specific business rule.
@Laflamablanca969
@Laflamablanca969 4 года назад
I find formatting with Resources is much more flexible
@Darren502
@Darren502 5 лет назад
This is a great ep. Thx for showing us this. Would you make a video on caching?
@golubevblog2279
@golubevblog2279 4 года назад
WONDERFUL DUDE! KEEP GOING! U'RE A MAN!
@rolanddecasa4438
@rolanddecasa4438 3 года назад
Another good one! Keep it up bro! God bless you
@personal1872
@personal1872 Год назад
hi there, it's been long that you haven't published a video, I love your content, please start making videos again :)
@SimpleLangSolution
@SimpleLangSolution Год назад
Wow! This is amazing! You are a god!
@amirkaftari5188
@amirkaftari5188 3 года назад
dude come back and create amazing tutorials for us.
@KoganeNoYubi
@KoganeNoYubi 4 года назад
great stuff, but how would you combine repositories with API resources?
@2012potter
@2012potter 4 года назад
Awesome. You could've used Eloquent resources instead of format() right?
@melomancheto2761
@melomancheto2761 4 года назад
I do not agree on the part of format and transform. You can't choose format, formating is for dates for examples. What we are doing with this data is transforming it . But the tutorial and not only this one, all of them are awesome!! Keep up the great content. Something else is that the request has nothing to do with the Repository. The repo is just a middle layer between the database and the Controller (I use this example to be more close to Laravel). We need to pass all the data we need as params and never pass the Request outside of the Controller.
@loremipsum574
@loremipsum574 5 лет назад
Please create a SOLID pattern tutorial. It would help a lot of beginners like me.
@tarikhagustia939
@tarikhagustia939 5 лет назад
up
@CodersTape
@CodersTape 5 лет назад
Would you say it would be better to exclude Laravel from it and keep it simple with plan PHP?
@loremipsum574
@loremipsum574 5 лет назад
@@CodersTape I mean SOLID pattern in laravel. If you search on the web there's no such thing as SOLID pattern tutorial it would be you the first one will do it. There's a solid pattern tutorial but not complete.
@Eugene.g
@Eugene.g 5 лет назад
@@CodersTape SOLID principles and design patterns are pretty abstract, so real life examples with refactoring in Laravel would be awsome to see. I think youtube lacks this type of advanced content on how to structure a Laravel app and how to use patterns
@Yuri-sf5mx
@Yuri-sf5mx 5 лет назад
This is something i hear a lot from beginners and had issues with myself when i started using Laravel. Laravel is great because it's all very "loosely", but as a beginner you have no clue how to organize files/namespaces, how to name classes, how to write functions, how to separate things, ... But i don't think a solid "all use case" pattern is possible because not all project will fit this pattern. A pattern is required, but should be on project level and defined in the abstract layout of your project. Before the first line of code is written the pattern should be established.
@MrNescafe87
@MrNescafe87 3 года назад
thanks for your explaination for this pattern and it helps so much but i actually have some questions. i know the reason for using the repository pattern but isn't this is why we use services classes ? For example " Making a UserService Class and inject it in controller and retrieve the users like : $this->userService->getAll() ? And why using the map method to format the response and not use the resources ?
@asdf7972
@asdf7972 5 лет назад
Mannn i really love this course!!!
@RichardOpokuEngineer
@RichardOpokuEngineer 4 года назад
I have implemented the repository pattern before and this has been really helpful to add to my understanding. However, some folks somewhere on the internet claim that it should rather be a service layer and not repositories. I recently had to refactor one source code to reflect *services* instead of the *repositories* I had already implemented. I need help understanding these further.
@CodersTape
@CodersTape 4 года назад
The service layer is the abstraction of the controller where the repository is the abstraction of the model. Typically you inject a repository into the service layer so you would still need both and it's just yet another abstraction layer between the view and the controller. So the order would be Controller > Service > Repository > Model is it better? I can't agree that it is in most cases. I think it's just hiding away bad code design but I am open to seeing some code samples. :)
@truthseeker2171
@truthseeker2171 4 года назад
@@CodersTape Wow, that's quite interesting. I am implementing a payment gateway (API) with an ecommerce app where I would like to have a lot of the business logic in the services and then manipulate the data using Repositories. But while following the above structure, *Controller > Service > Repository > Model* where will FormRequests come in for validation?
@haki3018
@haki3018 4 года назад
using request() in repository very nice
@vimkndll4171
@vimkndll4171 4 года назад
mind blowing video I have ever seen in the youtube
@SamehNabilAhmed
@SamehNabilAhmed 5 лет назад
you are awesome dude
@CodersTape
@CodersTape 5 лет назад
Thanks! Happy to help
@mohamedtalaat8945
@mohamedtalaat8945 4 года назад
Thanks for this great episode!
@mohaimenkhalid3844
@mohaimenkhalid3844 3 года назад
just a awesome video bro!! thanks a lot bro
@robert5488
@robert5488 5 лет назад
Thanks very much for these videos! They are brilliant, concise and very clear. Better than Laracasts. Would love to see more videos on design patterns and clean code fundamentals.
@JordiViure
@JordiViure 5 лет назад
Great! But.. this actions implemented in the repository can not be implemented inside the model? What s the difference? Thanks!!
@CodersTape
@CodersTape 5 лет назад
The difference is that if you don’t want to use a database or Eloquent, you can’t use the model. You can write a flat file implementation for example or use Redis or anything else you can think of to provide the data, not just a traditional database. It can even be provided by an API.
@vrabecm
@vrabecm 5 лет назад
Dude, nice tutorials. Only 1 cent from me: I think repositories should be used entirely for one purpose - retrieving data. Update, store and delete functions should be found in the model or a Service.
@CodersTape
@CodersTape 5 лет назад
I’ve seen it both ways in the wild. And I see both points of views.
@vrabecm
@vrabecm 5 лет назад
@@CodersTape Yeah, I agree, it's a personal opinion. Anyway, keep up with the videos, they are absolutely amazing.
@cedaesca19
@cedaesca19 5 месяцев назад
With this implementation, isn't the repository tightly coupled to Eloquent? why not DI?
@joshbarros1995
@joshbarros1995 3 года назад
Nice video! Do you intend to teach how to apply Services, TDD and Domain Driven Design on Laravel 8?
@manzadey
@manzadey 4 года назад
Eloquent is already a repository isn't it? Does it make sense to create another repository above the repository?
@siddharajsinhzala4229
@siddharajsinhzala4229 4 года назад
If I will not use interface for repository and directly inject repository into controller then is it correct? Or is it compulsory to use interface with repository patterns? Or what is benefits to implement interface in repository? I bit confused. Please help me to clear this confusion. Thanks ☺️
@Brianle180
@Brianle180 4 года назад
I am wondering that in this case, what is correct when we put the interface’s binding in ‘boot’ or ‘register’ function?
@dgloria
@dgloria 4 года назад
What's the difference between this and the resources? And how to handle more than one table?
@Paltibenlaish
@Paltibenlaish 4 года назад
question> why dont use the model to write directly the methods there??? why extra layer of abstraction?
@shirjeelkhan
@shirjeelkhan 5 лет назад
Great work...please go ahead. When is the next one e8 ?
@djanthony6662
@djanthony6662 4 года назад
I think some of these concepts could be done by using Query Scope for readability if you are using Eloquent: $customers = Customer::isActive()->orderBy('name', 'asc')->withUser()->get(); then pass that to API resource class for formatting: use App\Http\Resources\CustomerResource; return new CustomerResource::collection($customers);
@juanmanuelmazariegos4598
@juanmanuelmazariegos4598 3 года назад
Hello, amazing video, sorry, where going the logic?
@issaissifou3579
@issaissifou3579 2 года назад
Thank you so much!
@ristekostadinov2820
@ristekostadinov2820 4 года назад
If more than one class implements the CustomerRepository then in boot method of the provider we should register both of them (the interface with the first class and the interface with the second class) ? For example you can implement the interface with 2 classes one with pure eloquent ORM and second class with query builder
@jnjmedia8321
@jnjmedia8321 3 года назад
Is it really necessary to call/assign the CustomerRepository in the constructor or optional? Wouldn't it make the controller a little bit slow since every time we call the controller, the constructor also runs.
@Mohsen-i5z
@Mohsen-i5z 3 года назад
I enjoyed it. thanks
@jhonata13souza
@jhonata13souza 3 года назад
very nice, thanks!!
@richardjustinesoriano304
@richardjustinesoriano304 3 года назад
Thank you! 😄
@Kortess
@Kortess 5 лет назад
Hi, are there any plans for Docker lessons?
@topalidinka
@topalidinka 4 года назад
Thank you 👍
@irfanullahshakir3568
@irfanullahshakir3568 4 года назад
Outstanding
Далее
Laravel 6 Advanced - e1 - Service Container
23:27
Просмотров 273 тыс.
ОБЗОР ПОДАРКОВ 🎁 | WICSUR #shorts
00:55
Repository Pattern
11:08
Просмотров 67 тыс.
Laravel 6 Advanced - e2 - View Composers
22:12
Просмотров 69 тыс.
Laravel 6 Advanced - e6 - Pipelines
28:53
Просмотров 52 тыс.
Laravel + Service Pattern + DTOs = ❤️❤️❤️
17:52
Laravel Origins: A PHP Documentary
33:27
Просмотров 157 тыс.
3 Levels of Vim Refactoring
7:48
Просмотров 38 тыс.