Junior Code Review: Laravel Routes, Middleware, Validation and more
Vložit
- čas přidán 25. 07. 2024
- As a part of my new Laravel mentorship program in my home country Lithuania, I started doing code reviews of my student developers. Here's a 20-minute example that I decided to publish on CZcams - should be useful to you guys, too.
00:00 Intro
01:33 Route Grouping
04:08 Shorter Middleware Class
07:01 Middleware with Parameters
09:06 Migrations with Foreign Keys
10:32 Controller Index Refactor
14:03 Code Styling
14:46 Store and Validation
18:00 Update and Route Model Binding
Related resources:
- Route grouping: laravel.com/docs/8.x/routing#...
- Middleware with Parameters: laravel.com/docs/8.x/middlewa...
- Migration foreign keys: laravel.com/docs/8.x/migratio...
- PHP Ternary operator: www.codementor.io/@sayantinid...
- Eloquent "When" method: laraveldaily.com/less-know-wa...
- Code Styling and PSR-12: blog.quickadminpanel.com/psr-...
- Laravel Validation with Form Requests: laravel.com/docs/8.x/validati...
- Route Model Binding: laravel.com/docs/8.x/routing#...
- - - - -
Support the channel by checking out my products:
- My Laravel courses: laraveldaily.com/courses?mtm_...
- Laravel QuickAdminPanel: quickadminpanel.com
- Livewire Kit Components: livewirekit.com
- - - - -
Other places to follow:
- My weekly Laravel newsletter: us11.campaign-archive.com/hom...
- My personal Twitter: / povilaskorop - Jak na to + styl
"Juniors don't be afraid to show your code. Seniors don't attack the juniors that the code is bad. We all start somewhere."
So much this... I've been doing Software Dev for 26 years, PHP for 16 years, and Laravel for the last 2.5, and I learned something from this video. So I'd also add "Seniors, don't assume you know everything, and your way is the only way."
@@JimOHalloran Every day there is new oppurtunities to learn things, we shoudn't feel ashamed to do so !
Absolutely, thankfully my team lead adopts this mentality as well. Such a good quality to have in leadership and development in general.
The delete action using "GET" instead of "DELETE" might expose the user to CSRF attacks. That one should be changed for security. (I hope this observation can be useful for someone).
buen dato , maestro.
3:54 he mentioned it
@@digitalminister5687 Yes, I know, I just wanted to point out the potential security issue, that's all :) I also record videos and it's challenging if not impossible to cover everything in one video no matter the length.
styde needs updated videos on laravel 8 ;)
John Smith what does that have to do with this video? And FYI I do have tons of videos in L8, just not in my CZcams channel.
I liked the video format. And today I noticed that I'm not a junior anymore.
Lmao
Omfg. This is like those "very satisfactory" videos with people slicing colored clay, but with coding.
Such a rewarding feeling to watch.
Yes ! Please ! More code reviews videos ! As a junior I can't state how valuable this is. Thanks for everything !
Love code reviews like this! Please do more. It's a great way to learn. Thanks!
Amazing concept! Please do as many videos as you can easily. This is great content. Keep up the awesome work. 👍👍👍
Great video, love the format. Never knew about the eloquent "when" method. Good way to plug gaps in your knowledge
Very nice sir, most of the tutorials on net only deals with beginners things, ie how to start or more advance things, but you literally deal with minor problems which developers actually face, while developing something. I highly respect you for your efforts.
Such a phenomenal idea for the video. This what I was looking for back when I started just a year ago. I always had a feeling that new/beginner developers want to see what a real application looks like, how every part of it looks like, not just some examples and basic principles. Or even see other beginners how they code and it all looks like. So interesting. I will admitted, I do have some mistakes in common with the "author" of the code you reviewed. You should keep doing videos like this, it's really useful in terms of improving and seeing that we all actually make common mistakes, I'm no different than many other guys who started. It's a normal learning process and we shouldn't be ashamed of our silly, but important mistakes.
Really grate video sir. 🙂
Cheers
This means a lot of helpful to jr. developers to learn.
I have seen many videos. many of video creators Assumes that you were aware about the mistakes that users do. but actually the fresher or junior developer wasn't aware of that. *And this is really fantastic video to identify mistakes and correct them*.
Extremely helpful!! I started coding in Laravel a few months ago, and while I know how to get things done, this helped me learn how to do them the right way.
Thank you!
Please make this into a more regular series, very helpful! Thank you.
I've never written a line in PHP but still watched till the end, you never know when you gonna need this.
Great review, very satisfactory.
Eres grande amigo. No porque sepas mucho, sino por darte el tiempo de ayudar a los que saben menos. Saludos desde Chile.
Cool video concept. Definitely do more of these as they’re interesting. I learnt a few things too 🥳
Hello sir
You are the most humble and kind person in the region. You always appreciate others for working hard instead of dominating them for mistakes, and helping them grow each time. I think your contribution to this growth of laravel is remarkable.
Help is only help, whatever form it may be given, and I am grateful for your efforts and love.
Loved your disclaimers!! Great video! Thanks for sharing. I'm also a junior developer and learning a lot from your videos.
I have completed my last project fully with query builder only. This video help me to under stand the standard of code. Thank you so much sir. You videos help me lot
Awesome video, happy to see that I'm doing at least some of the things right, but even happier to see what is expected from me to write a better code in laravel.
Please make more videos like this!
I loved to check what I am doing wrong and how to fix it and make it a better code !
Thank you this was awesome! As someone just refreshing their Laravel knowledge I learned so much
I really enjoyed and learned watching this one as a junior programmer!
i agree with you on this statement
"as junior dont be afraid to make mistake (but take responsibilty on that)"
"as senior dont attack your junior (we have to start somewhere right)"
huge respect to you!!
Thanks for your videos Povilas, I am also beginner laravel Developer, i'm your fan, your videos are very helpful. When I start earning money i will obviously buy your " eloquent course"
Your one video > Tones of Learn laravel from strach for Inermediates.Thank you Sir, have a better life everyday.
Im experienced web developer, but a c# one. Have no idea why this video appears in my recommendation, but it's ASWESOME.
For me It was a good overview of PHP/Laravel development). Without any experience I understood 100% of it! Thanks.
Great video, need more of this unique learning, particularly useful for any dev level. Amazing advice to junior and senior at the video introduction. 👏
really incredible video quality, learning from your lessons constantly. At work, I recommend your videos to colleagues. Thank you for such quality content!
hello from Russia, city of Stavropol: 3
I haven't done Laravel in years, but it was still interesting to watch :-)
This video format is great for the channel as the comment/view ratio it gets. Some stuff is obvious but other is just awesome. Keep this series coming along.
That $request->validated() and $fillable combination was on another level. Got to learn something new 😄
@@mbparvezme Validation messages can be set in the Request Class created using " artisan make:request" command. Laravel will take care of the rest. And for the frontend you do everything same as before.
Also check out the laravel documentation on "The Basic > Request" section it explains it beautifully. You can also use custom Rules inside the request class instead of if statements in the controller. 😉
@@0xshashwat Thank you for your reply. It was my fault. I just forgot to include the "Accept: application/json" header in the request. That is why it send me a response with a redirect (back). But with the appropriate header, I got the error message.
Best and crystal clear tutorial, thanks a lot 🙏
after watching this video i’am not a junior developer anymore 😁 , more videos like this sir. this is awesome, thank you povilas ❤️
We need more this type of videos. Thank you.
Another note: if you're looking to refactor your routes, please take the time to make some quick feature tests that hit your routes so you can test when you change anything if something breaks and follow the errors to refactor it correctly.
Nice video and so many tricks and advises in just 20 minutes. Thanks
The command in PHPStorm to highlight the next occurrence of a word is Ctrl+G on Mac and Alt-J on windows. On vscode it’s ctrl+D. Rather than moving the mouse and highlighting line by line
Great content!
Hope this series got more video. very helpful for all. thanks a lot.
Thanks alot Sir
This video is just so golden for me
Will sure watch more of this kind of your videos 🔥🔥🔥
This chanel is gold... Great video, as always 🔥
For this code review, I would also go for constants, instead of hardcoding Roles ID everywhere. Like ROLE_MEISTER = 0, and so on. Should make the code way more readable.
Nice video, very helpful for junior laravel devs
Details that can simplify your life a lot!
Very cool how you give tutorial, thanks for the video man!
Awesome video, perfectly explained, easy to understand, high value tips
Thanks a lot . Please , make more video like this. It's very educative.
Wish I could like this video 10x. What a great tutorial
Keep it up sir. I always wait for your videos. I learnt more things in laravel.
I love these , I hope you still make them
I've made a lot of them, until I started repeating myself. See the Playlists of the channel, there should be one with reviews
This tutorial is very helpful!
Thank you so much!
Great video. As for multi-line edit. Just double tap ctrl, and use arrow down to select all lines. Hit "End" to get the cursor to the same location on each line. Now remove the middleware in one go.
or just hold alt as your move the cursor
Refactoring is like ointment for my soul. I don't even use php but this is such a great idea for youtube content.
This was really great, had to pause a lot to think... :). Really useful to see.
yes please do more refactoring session. Thank you!
Thank you for the video. We need more like this. Keep it up!
very very helpful sir you help me very much in laravel as i am also a laravel developer . Really thanks for your knowledgeful videos and keep ahead sir
one more time thank you very much
Can you please make more refactoring videos like this? please!! It was soo good!
Bravo! what a great video, I've learned a lot, thank you Sir, keep it going.
Please create more videos like this. This is so helpful.
Awesome! Really really great idea for video. Practical examples...
Thanks , boss these kind of videos have great tricks... we need more and more
after 7 months of coding in laravel I finally got a hang of its basics... but this video shows me I just scraped the tip of the iceberg...
i just watched till 1:13 and i start loving you.... This is how juniors shud be treated... Love You Sir.
Wow, I don't even code in Laravel but I couldn't stop watching. I wish there was something like this for code in Ionic, Angular, Vue or Firebase.
Great video,we need more videos like this
Thanks. It was very helpful. A lot of tips that I think about every time when write code like "How to do in this situation" or "How it should be in correct way"?
What a video! Thanks! It 'was so useful!
wow , it's amazing , thank you very much , I got a lot of information in this video
More of this, please! I am just starting in the laravel world :D
need more like this. Code Review. Thanks for this share
Thanks for the wonderful video.what I have been looking for.
Great Video. I would love to watch more videos like this.
In PHP Storm you can use "Alt+J" to select next occurrences of the selected code or use "CTRL+Shift+Alt+J" to select ALL occurrences of the selected code.
Thanks for this. Please do more of this 💕
simply, LEGEND !
Thanks, I learned a lot ...
we need more videos like this .thank you for this video
Great senior tips, thanks alot 👍🏻
I am new to Laravel and some of these things are how I coding with Laravel, some are new and I'm excited to get more.
This was really helpful! Thank you :D
big thanks for you , you are the best in youtube truly
You really boost the morale for LARAVEL for all junior devs.
You helped me alot with the $requests... I did it the same way as you mentioned but i left it inside the function what felt tottaly wrong and now i know why i had this feeling all the time
Pretty good review. Only thing I would have said more explicitly is that Material:all() returns a collection, so the where is using PHP code to do its job. It may not be as obvious to the junior that the all() sets up the query AND fetches, where as the where function of the Eloquent model is simply utilizing a query builder and get does the fetch.
The confusion mostly stemming from the collision of some function names in collections vs query builder for eloquent.
Great video Sir, thankyou so much.
useful, its always nice to watch videos like that one
Thank you teacher .. please do this more
thx povilas, really awesome, we want more and more videos like this videoo
Thank You. Very good tips for beginners. I learn daily really :)
Awesome video! Want more like these please
I don't even code on PHP but I enjoyed the video, mostly for the lessons on organization and cleaner code.
This video inspired me to learn more
You are doing nice work in this video. I like it
your youtube channel is very informative
I was just checking about Today's video 5 minutes ago 😁. Now here it is. Thank you Povilas.
Yeah, this one took longer time to produce than I expected. Started with idea that "I'll just give a few tips in 5 minutes", and published this video 4 hours later :)
Laravel daily sir, it help us alot because we are junior
Well then.. This 'refactoring' went so fast, I felt bad I couldn't follow everything. Time to brush up on my Laravel skills again.
Quality video by the way. THIS is how juniors improve and learn different code styles and refactoring.
This is really great, thank you. It's embarrassing to me that you probably just wrote more code in 20mins than I wrote all day today.
Awesome video, thank you very much!
Excelent video! 👏🏻👏🏻👏🏻
It very help me as baginner aravel code. Thank you sir
Thank you so much ! so interesting to see ! :D
Awesome explanation.