No video

Laravel API and Repositories: 3 Tips from Code Review

  Рет қаралды 12,482

Laravel Daily

Laravel Daily

Күн бұрын

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.
Repository Dip-Ghosh/social-network-api: github.com/Dip...
Original tweet: / 1456925406108348424
Related videos:
- Laravel Code Review: Why NOT Use Repository Pattern? • Laravel Code Review: W...
- Laravel Services and Repositories: 3 Example Projects • Laravel Services and R...
- Example of Interfaces in stefanzweifel/screeenly laravelexample...
- Eloquent API Resources: Pagination laravel.com/do...
- DRY Laravel: Use Base Controller For Common Responses • DRY Laravel: Use Base ...
- DRY: Shorter Laravel Responses with Macros • DRY: Shorter Laravel R...
- Code Reviews - Playlist: • Junior Code Review: Be...
- - - - -
Support the channel by checking out our products:
- Enroll in my Laravel courses: laraveldaily.t...
- Try our Laravel QuickAdminPanel: bit.ly/quickad...
- Purchase my Livewire Kit: livewirekit.com
- View Laravel Code Examples: laravelexample...
- Subscribe to my weekly newsletter: bit.ly/laravel-...

Пікірлер: 49
@AmrGamal878
@AmrGamal878 2 жыл бұрын
totally agree with your comments , personally I was overusing the repository pattern in laravel, but this has come to end
@BsiennKhan
@BsiennKhan 2 жыл бұрын
You say over using, From suggestion of povilas and my own personal experience, repository IS overkill in many projects and not needed for Laravel mostly. I have same opinion on PDO vs MySQLi. Never in my life I've seen or did swap of database. MySQL is all it always has been. It's relevant to repository because PDO is such one.
@amori7410
@amori7410 2 жыл бұрын
@@BsiennKhan but PDO is used for prepared statements, i.e. dissalow sql injections, also it has unique errors and exceptions and overall PDO is better suited for OOP. Even Laravel is using it inside Eloquent
@JonnyJKF
@JonnyJKF 2 жыл бұрын
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...
@geneartista9714
@geneartista9714 2 жыл бұрын
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.
@antaramohapatra2076
@antaramohapatra2076 2 жыл бұрын
It’s perfect. Easy to understand. I really love it
@spartacusyusuf9989
@spartacusyusuf9989 2 жыл бұрын
Hopefully you do tutorials on payments gateway integration like coinbase, paypal and others
@LaravelDaily
@LaravelDaily 2 жыл бұрын
I don't actively work with those, so can't do tutorials on them
@javiershaka
@javiershaka 2 жыл бұрын
great meme for explain the status.
@librasulus
@librasulus 2 жыл бұрын
true, I loved it, and it explains the problem perfectly.
@ShinjaeKang
@ShinjaeKang 2 жыл бұрын
Easy to understand. I love this channel :)
@Stoney_Eagle
@Stoney_Eagle 2 жыл бұрын
The combination between the interfaces and custom pagination let's me think it's preparing for a different ORM.
@WillianLevinskiKeller
@WillianLevinskiKeller 2 жыл бұрын
I don't understand why some developers doesn’t use PHPCS, even for just builtify their code.
@MohamedGaber-qs6vt
@MohamedGaber-qs6vt 2 жыл бұрын
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
@rizwan8025
@rizwan8025 2 жыл бұрын
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?
@ShailendraSharmaDark
@ShailendraSharmaDark 2 жыл бұрын
search about bulk insert records in laravel
@LaravelDaily
@LaravelDaily 2 жыл бұрын
That's a good idea for a video, added to my to-do list for the next week
@abdulrehmandar8541
@abdulrehmandar8541 2 жыл бұрын
@@LaravelDaily it's is good question if you can add one more query to this is let the data is coming from a paginated api. how to work with a paginated api.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Video published: kzbin.info/www/bejne/pHjGiGegh56pgsk
@ShailendraSharmaDark
@ShailendraSharmaDark 2 жыл бұрын
@@abdulrehmandar8541 I worked with paginated api, where I used a function to fetch record from paginated api and used recursion to call the same api with different page number and if there is no records in the api call then I break the function call
@paulocardoso670
@paulocardoso670 2 жыл бұрын
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.
@phil86_
@phil86_ 2 жыл бұрын
Very interesting review
@shaungbhone8368
@shaungbhone8368 2 жыл бұрын
Could you make tutorial for "handling laravel projects at staging and prod"? Thank you.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Handling what exactly? And actually if you search my channel for "staging", you will find a few videos
@shaungbhone8368
@shaungbhone8368 2 жыл бұрын
@@LaravelDaily "How to deploy laravel project?" something like that. It's just advice. It's doesn't matter. Thank you. Mr. Daily. I just want to learn your way.☺
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Here are my videos about it: kzbin.infosearch?query=deploy Also, older article: laraveldaily.com/how-to-deploy-laravel-projects-to-live-server-the-ultimate-guide/
@shaungbhone8368
@shaungbhone8368 2 жыл бұрын
@@LaravelDaily Thank you.
@anandetheophilusterfa5034
@anandetheophilusterfa5034 3 ай бұрын
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
@nabilaldhaleai5213
@nabilaldhaleai5213 2 жыл бұрын
Wonderful feedback ... thank you
@belce1982
@belce1982 2 жыл бұрын
Thanks as always!
@yupe_team
@yupe_team 2 жыл бұрын
Using Auth::id in repository is more evil then repository itself.
@NotBeHaris
@NotBeHaris 2 жыл бұрын
Please make a video series on database structure for possible ways. Like when we have to store images. Database structure is very tricky always.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
I have a full course: laraveldaily.teachable.com/p/how-to-structure-database-in-laravel For images, I recommend Spatie media library package, with polymorphic relationships
@quadradosuave
@quadradosuave 2 жыл бұрын
// thank you for your content!
@user-pu8ek9xr2w
@user-pu8ek9xr2w 2 жыл бұрын
Most of time overengineering is pure evil. May be worst of all) Good code is code that is simple and easy to read.
@JediJide2
@JediJide2 2 жыл бұрын
A lot of developers think the art of good coding is an elaborate exercise in obfuscation. And to be fair, many are not brought up to or have enough experience to adopt KISS (Keep it Simple Stupid) principles.
@geneartista9714
@geneartista9714 2 жыл бұрын
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)
@LaravelDaily
@LaravelDaily 2 жыл бұрын
That's also an option, all good
@geneartista9714
@geneartista9714 2 жыл бұрын
@@LaravelDaily geez thanks sir, glad to know I'm doing it right. If you have not tried creating a content about laravel I'm sure I'm nowhere near what I've achieved now I'm still a student but sooner or later I'll start buying your courses cause I know there's still a lot to learn from a laravel maestro like you.
@rossco5551
@rossco5551 2 жыл бұрын
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?
@LaravelDaily
@LaravelDaily 2 жыл бұрын
It's in the description of the video, but if you haven't found it: kzbin.info/www/bejne/f6K1nHRvprN6hNE
@rossco5551
@rossco5551 2 жыл бұрын
@@LaravelDaily Ah yes, thank you - sorry I completely overlooked that one!
@haroldpepete
@haroldpepete 2 жыл бұрын
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
@GergelyCsermely
@GergelyCsermely 2 жыл бұрын
Thanks
@raimonds.L
@raimonds.L 2 жыл бұрын
I'm using Route::prefix()->group() without as. Am I the weird one?
@ilhamfajriumar9085
@ilhamfajriumar9085 2 жыл бұрын
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
@LaravelDaily
@LaravelDaily 2 жыл бұрын
There's no "should" in such choices, you use the pattern that you personally prefer and which works for you. Regarding notifiable, I think it's used by default in Laravel notifications, I don't think it's worth the video, it's all in the docs. Unless you have some specific usage of notifiable in mind?
@ilhamfajriumar9085
@ilhamfajriumar9085 2 жыл бұрын
@@LaravelDaily i check the notifiable source code and it had 2 other traits which is database notification and route notification ( iirc ), i was curious about the database one basically
@LaravelDaily
@LaravelDaily 2 жыл бұрын
kzbin.info/www/bejne/a3W1dqh3q6uhptU this video
Laravel Code Review: Why NOT Use Repository Pattern?
14:21
Laravel Daily
Рет қаралды 77 М.
Faster Eloquent: Avoid Accessors with Foreach
9:35
Laravel Daily
Рет қаралды 53 М.
UNO!
00:18
БРУНО
Рет қаралды 5 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 7 МЛН
Logo Matching Challenge with Alfredo Larin Family! 👍
00:36
BigSchool
Рет қаралды 22 МЛН
Eloquent Performance: TOP 3 Mistakes Developers Make
7:59
Laravel Daily
Рет қаралды 48 М.
When to use Traits, Interfaces, and Abstract Classes in PHP
15:08
Andrew Schmelyun
Рет қаралды 18 М.
Laravel: Why Observers and Event Listeners are "Risky"
8:45
Laravel Daily
Рет қаралды 26 М.
Laravel: Create Public API with Cache and Rate Limits
12:18
Laravel Daily
Рет қаралды 45 М.
Write Laravel, not PHP (feat. Aaron Francis) | 029
58:45
Backend Banter
Рет қаралды 15 М.
Laravel Validation: 12 Less-Known Tips in 13 Minutes
13:11
Laravel Daily
Рет қаралды 38 М.
SOLID Principles: Do You Really Understand Them?
7:04
Alex Hyett
Рет қаралды 160 М.
Laravel .env.example: APP_XXX Values Explained
9:59
Laravel Daily
Рет қаралды 18 М.
UNO!
00:18
БРУНО
Рет қаралды 5 МЛН