Laravel API and Repositories: 3 Tips from Code Review

preview_player
Показать описание
This time I'm doing a "surprise" code review for a person from Twitter and giving 3 tips related to APIs and to the repository pattern.

Related videos:

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

totally agree with your comments, personally I was overusing the repository pattern in laravel, but this has come to end

AmrGamal
Автор

I've been working with PHP for about 12 years and only worked on one project with a legitimate reason to use various repositories contracted to the same interface along with a data mapper to take data in different formats from various external APIs outside of our control and map them into our own data models we can work with consistently. In that project they worked really well but also made everything take a long time to develop. Everywhere else: just keep it simple...

JonnyJKF
Автор

100% agree with your suggestions, laravel itself has already a repo pattern and it's pretty perfect in it's own way, adding another pattern is just overkill.

geneartista
Автор

It’s perfect. Easy to understand. I really love it

antaramohapatra
Автор

Hopefully you do tutorials on payments gateway integration like coinbase, paypal and others

spartacusyusuf
Автор

Easy to understand. I love this channel :)

ShinjaeKang
Автор

by this approach he get all the table data from database and load them in server memory then paginate and send some to front end, which is not the best way to pagination because in much data maybe lead to not enough memory on the server

MohamedGaber-qsvt
Автор

The combination between the interfaces and custom pagination let's me think it's preparing for a different ORM.

Stoney_Eagle
Автор

Maybe the author didn't know the Laravel Resource feature. In my opinion the repository pattern in laravel is good only for very specific cases, but on most cases, the Models can handle stuffs enough, Eloquent is very powerful, people looks like they don't know the framework features, maybe they should read more the laravel documentation, I don't know.

paulocardoso
Автор

Could you make tutorial for "handling laravel projects at staging and prod"? Thank you.

shaungbhone
Автор

Hi sir, I have an array of almost 1000 records. I want to check against a single record if not exist in DB insert it if exits then skips it. I found a solution that with the loop I can do firstOrCreate against single. with this method, the system will be too slow because DB will call 1000 times. is there any method to and insert in one query?

rizwan
Автор

I don't understand why some developers doesn’t use PHPCS, even for just builtify their code.

WillianLevinskiKeller
Автор

Please make a video series on database structure for possible ways. Like when we have to store images. Database structure is very tricky always.

NotBeHaris
Автор

I'm developing a POS system in Laravel and i have generated a barcode using Milon package with EAN13 code type but unfortunately i get different codes when scanned.

Kindly do a video on how to go about this.

Thank you

anandetheophilusterfa
Автор

Regarding the creation of standard api response. I don't know if I'm doing it right but I created a make:trait command and in this trait I created my api responser trait class containing methods called (success, error, no content, ..etc)

geneartista
Автор

Using Auth::id in repository is more evil then repository itself.

yupe_team
Автор

Hi Povilas, which is the link you referred to in the video about your tips/recommendations on parking the API response logic actually in Laravel's controller class please?

rossco
Автор

i think he used pattern repository thinking in the future, maybe the project has to make use of new features and he needs to make new things in the database, he does not need a full refactor, he only needs new method to the interface and new implementations of those methods

haroldpepete
Автор

Most of time overengineering is pure evil. May be worst of all) Good code is code that is simple and easy to read.

puekxrw
Автор

I still confused on how and when to use service, event, listener, lets just say i have several models that has different historic statuses (same structure), all had verified and rejected status, and had different things to do after verification and rejection.

Should i put the verify and reject logic inside the model or put in Service class, should i use event and listener for the next stuff to do or just add it after the logic etc, it still bugging me

Ouh and 1 more thing, do you have any video that explain notifiable trait, i think it's a cool trait but rarely used for somereason

ilhamfajriumar