I was looking for channel like this for so long, till now I haven't found a dev which is advanced and also shares his knowledge of architecture beyond controllers
Beyond pro level, watched that video before going to sleep. Now its 4:44 am I'm still watching it again and again , learning every topic that showed! Thanks man!
Thanks a lot for making these kind of videos. Recently discovered your channel and slowly watching your videos. It's amazing how you make subjects that were unknown to me very easily understandable and right away I can see the use cases for my own projects because you show real-life examples. An amazing channel and huge compliments to you as a teacher.
That's insane man, from many lines of codes to, two lines of code. That's incredible, thanks much for sharing this with us...i'm new in Laravel and this is my dream to code like this.
Can be considered but if you declared a fillable array on the model it won't assign anything other than those values declard in the model. But from readability you're right
@Lukas Korbitsch I know that, assume you have model Customer with fillable fields: name, email, status, and some user allowed to update ONLY the status of customer (set active or inactive), in that form user could inject input name or email that Shouldn't updated
How could I be so wrong for so long? Thanks for this...this is gold!
2 ปีที่แล้ว +1
idk, youtube recommends these with some delay :D I just started doing the same thing with my huge controllers at work, and now I see this in my feed :D How cool :)
Reasonable for fat actions. If applied for small ones, now instead of quickly seeing all functionality at single look , you will have to navigate +5 or more extra files.
Thanks for the great tutorial. But I think it can sometimes make other developers worried if they are not following the same path. For example now the controller is very tiny. They are debugging an issue, they see that some data is being updated, but where is it? I have seen the observers for the first time here. Same may be the case with many people. This is indeed handy and keeps the code clean and short, but can sometimes create confusion. When it comes to FormRequests, yeah they are common, so if a developer does not find validation in Controller, they wiill directly think that yeah it can be in the FormRequest. So I am in 50 50 for using those observers and the like stuff. they can complicate things a little bit.
i'm grateful that we have teacher like you, when i'm doing programming i study core php for 1year and i hate laravel so much but when i find job as programmer they required me to study laravel (the framework most i hated) i hate laravel because im also security researcher and i know laravel have zero day exploit but i have no choice i need to study laravel and one day youtube suggest your channel now im fully understand the laravel and what is advantages of laravel and now im started to love it thanks man! you save me to find awesome job now im junior developer i'm already 3months in job as junior programmer/developer but i think my knowledge is enough as senior developer thank you very much bro. but i have request im hard to understand and refactor the Policy/authorization the most important part of developing app, please help me to understand newbie like me the how to use policy and add custom method using authorizeResource() and resourceAbilityMap() Thanks bro
The MVC concept is to put all the logic functions model (such word counting), the controller to interact between the model and the view. This is my basic understanding of MVC.
What is the difference between observers and events? I would rather use event over observer because code in controller tells me what happens. It's kinda hidden when you do it with observers. What do you think?
Good point, I agree with you. Another thing is that observers are mostly for MODEL observing, specifically for created/updated etc, and events are broader and can be used anywhere.
Basically in simple terms you can call Observers as Model Hooks where we can hook some code before or after Create, Update, Delete kind of stuff. Where as events are like when something happened. So basically I would put the Admin Notifiations code in Events where we could listen for more stuff. So I would delegate my code here. Eg: PostPublished Jobs on the other hand is like before something happens Eg: PublishPost There lies a thin line which coud confuse most of the developers but over the time you will get to know after using in much of the projects.
Although the code is clean there is something that bugging me and that is that it’s not apparent all these extra functionalities which makes debugging much harder. And I don’t mean in Laravel specifically. Unless some kind of mechanism has been set up like let’s say a plug-in system you are going to pull your hair out in a real world much complicated project
@@davidbasil3161 In general comments should be used when there is a complicated piece of code otherwise code should be self explanatory through the name of the methods and attributes IMO. Also in my experience if you have a code base with lots of comments it's most likely that people won't pay much attention to them. If there are some comments here and there it's much more alarming to fellow devs when they see these comments
2 ปีที่แล้ว
@@SaiyanJin85 tru. In years my code became so semantic, so I can send a screenshot to my project owner who has no clue about programming asking him if the business logic is okay, and he is able to validate it :D
Amazing video! I was searching for something like this for years. I always disliked most tutorials polluting the controller with "ifs" and "for" and validations.
Great video, I would also recommend using collection methods with anonymous function instead of foreach, for eg : $posts->each(function ($post) use ($otherStuff) { //Do here } You can also use &$parameter for sending your variable by reference and it will be saved after anonymous function, similar to pointer in C/C++
sir your videos are too gud and helpful , i even started your free course for beginners in laravel, and i m waiting if you will uplaod any course realted to vue and laravel api
one question, if you are new to this kind of project how do you know, that there is a service and an observer if you don't reference it in the controller?
Well, a lot of things may be outside of controllers, it's not only in the controllers you should look, you need to research all folders to understand how it is structured.
@@PovilasKorop yes, im still a beginner in laravel, but what it is very practical to me is to follow the view controller model, clearly defined in the routes/web. I hope to get more pro soon, :)
i am using maatwebsite excel package, is there a way to import data and check validation on some specific fields, if any record fails to match validation, record the whole rows in a report excel file with the error message or red color in that field text which are not proper (the reason why validation failed) and then finally after full import have and option to download error excel file. So that we can correct the fields and upload that file again.Do you have any tutorial like this. I will be highly thankful if you guide me how to do this, i have tried to read the maatwebsite excel package documentation, but it is not very much clear to me.
hi guys, great material here. I need to make a functionality to take a csv as a request and update multiple tables, how would be the correct way to afront this in laravel,?? (-the validation of the csv -creating records in many database and sending a response )
There's no one "correct" way. It depends on the complexity of your CSV, what kind of validation you need, and what you need to do after validation errors or after creating records. On each of the steps, there may be an error and you need to handle it in your way. You won't get such an answer in a simple TH-cam comment.
hello, lately I've been watching your videos a lot. many good things i've learn from you. thank you so much. but I have a question how to prevent race conditions when using observers or event listeners or services do you use lockForUpdate method? please make video about lockForUpdate, rollback related with observers, event listener, and services. thank you.
In a 15-minute video, I learned more than in 2 hours lessons! Thank you very much!
definitely
Agreed. I have been learning Laravel for 2 days and this is super helpful.
agreed
I was looking for channel like this for so long, till now I haven't found a dev which is advanced and also shares his knowledge of architecture beyond controllers
This is the best 15 minutes video I have ever watched. Amazing tips.
This is the best Laravel video I've ever seen.
Beyond pro level, watched that video before going to sleep. Now its 4:44 am I'm still watching it again and again , learning every topic that showed!
Thanks man!
In a 15 min video, I learned more than in 2 hours lessons! You're the best, Thank you very much!
Phenomenal! I have a good 3-4 hours of reading and experimentation to do after watching this.
This video has cleared so many concepts. not necessarily we apply all of these but so much information and practically displayed. Awesome Sir !
This video is 100% informative and 80% eyes hurting.
This was amazing. I never had seem so soft refactoring
Thanks and again: you're the best
Thanks a lot for making these kind of videos. Recently discovered your channel and slowly watching your videos. It's amazing how you make subjects that were unknown to me very easily understandable and right away I can see the use cases for my own projects because you show real-life examples. An amazing channel and huge compliments to you as a teacher.
This is one of the best laravel lessons on youtube
That's insane man, from many lines of codes to, two lines of code. That's incredible, thanks much for sharing this with us...i'm new in Laravel and this is my dream to code like this.
Also it will be better to user request->validated() instead of request->all() to insert the validated fields only
Can be considered but if you declared a fillable array on the model it won't assign anything other than those values declard in the model. But from readability you're right
Yes, Somebody could inject html input and randomly guessing the another input that shouldn't update in that form (included in fillable variable)
@@AnggaAriWijaya laravel will only fill values which (if) are specified in the fillables array on the model
@Lukas Korbitsch I know that, assume you have model Customer with fillable fields: name, email, status, and some user allowed to update ONLY the status of customer (set active or inactive), in that form user could inject input name or email that Shouldn't updated
@@AnggaAriWijaya ah I see where you going yeah you're right. But in this scenario I wouldnt build it like thst
Wow!!! The best refactory that I saw! Congrats!
Thank u so much sir for giving us your precious time . I started following you and you are so good.
How could I be so wrong for so long?
Thanks for this...this is gold!
idk, youtube recommends these with some delay :D I just started doing the same thing with my huge controllers at work, and now I see this in my feed :D How cool :)
Reasonable for fat actions. If applied for small ones, now instead of quickly seeing all functionality at single look , you will have to navigate +5 or more extra files.
Exactly, instead of 20 lines, now hundreds in many files, without any comment in controller.
Brilliant... Looking forward to more of such refactoring videos.
Wow this was so well done. Short and so much informative. Thanks
Thanks for explaining, was searching for this kind of video for a while. It all makes a bit more sense.
Thanks for the great tutorial. But I think it can sometimes make other developers worried if they are not following the same path. For example now the controller is very tiny. They are debugging an issue, they see that some data is being updated, but where is it? I have seen the observers for the first time here. Same may be the case with many people. This is indeed handy and keeps the code clean and short, but can sometimes create confusion. When it comes to FormRequests, yeah they are common, so if a developer does not find validation in Controller, they wiill directly think that yeah it can be in the FormRequest. So I am in 50 50 for using those observers and the like stuff. they can complicate things a little bit.
a good solution would be to add a comment to inform the developers that that specific action is handled in an observer
@@MahmoudMohsab yes you are right.
@@MahmoudMohsab Thats exactly what I was asked to do when I submitted PR .
the best example you will see it the world!
Thank you ..
very good, I was impressed, I will take your course
OMG! now it is two lines of code. Amazing!
i'm grateful that we have teacher like you, when i'm doing programming i study core php for 1year and i hate laravel so much but when i find job as programmer they required me to study laravel (the framework most i hated) i hate laravel because im also security researcher and i know laravel have zero day exploit but i have no choice i need to study laravel and one day youtube suggest your channel now im fully understand the laravel and what is advantages of laravel and now im started to love it thanks man! you save me to find awesome job now im junior developer i'm already 3months in job as junior programmer/developer but i think my knowledge is enough as senior developer thank you very much bro.
but i have request im hard to understand and refactor the Policy/authorization the most important part of developing app, please help me to understand newbie like me the how to use policy and add custom method using authorizeResource() and resourceAbilityMap()
Thanks bro
I'm sorry but what do you mean by laravel has zero day exploit?
and doesn't the exact same thing apply to every major open source language/framework ?
Потрясающе! Спасибо огромное :))))
This was insanely helpful, thanks so much. Laravel blows me away everyday
Its realy a nice and comprehensive demonstration, learnt alot
I really appreciate your work. kudos
great explanation! PS. As you also showed only([...]), you could've also used $request->validated() instead of ->all().
The MVC concept is to put all the logic functions model (such word counting), the controller to interact between the model and the view. This is my basic understanding of MVC.
What is the difference between observers and events? I would rather use event over observer because code in controller tells me what happens. It's kinda hidden when you do it with observers. What do you think?
Good point, I agree with you. Another thing is that observers are mostly for MODEL observing, specifically for created/updated etc, and events are broader and can be used anywhere.
Good points of view, guys. I agree with all you said.
Basically in simple terms you can call Observers as Model Hooks where we can hook some code before or after Create, Update, Delete kind of stuff.
Where as events are like when something happened. So basically I would put the Admin Notifiations code in Events where we could listen for more stuff. So I would delegate my code here. Eg: PostPublished
Jobs on the other hand is like before something happens Eg: PublishPost
There lies a thin line which coud confuse most of the developers but over the time you will get to know after using in much of the projects.
Although the code is clean there is something that bugging me and that is that it’s not apparent all these extra functionalities which makes debugging much harder. And I don’t mean in Laravel specifically. Unless some kind of mechanism has been set up like let’s say a plug-in system you are going to pull your hair out in a real world much complicated project
@@davidbasil3161 In general comments should be used when there is a complicated piece of code otherwise code should be self explanatory through the name of the methods and attributes IMO. Also in my experience if you have a code base with lots of comments it's most likely that people won't pay much attention to them. If there are some comments here and there it's much more alarming to fellow devs when they see these comments
@@SaiyanJin85 tru. In years my code became so semantic, so I can send a screenshot to my project owner who has no clue about programming asking him if the business logic is okay, and he is able to validate it :D
NOtifications can be Queueable, no need to make Job.
Exactly
Congratulations! You really bring valuable content in your videos!
Amazing video! I was searching for something like this for years. I always disliked most tutorials polluting the controller with "ifs" and "for" and validations.
Great example and nice explanation
This was really helpful! Thank you.
Thanks a lot! Keep doing examples like this, really useful for me
Perfect! Great video, I learned a lot.
Great video, I would also recommend using collection methods with anonymous function instead of foreach, for eg :
$posts->each(function ($post) use ($otherStuff) {
//Do here
}
You can also use &$parameter for sending your variable by reference and it will be saved after anonymous function, similar to pointer in C/C++
You have great knowledge of Laravel..
the best video! You're the best, man !
magic method __LaravelBusiness thank you :-)
Awesome, very helpful
Thanks as always.
Thanks. It's a great tutorial!
Awesome tutorial 🙏 Thanks a lot man!
Great Tutorial @Povilas!
its great video and u explain so simply thanks man
Thanks for your effort
Thanks for this video! It's so helpful!
omg this video so amazing tks you so much for share your knowledge
Awesome video! Thank you!
What's the use case between a service and adding a method like that to the Post model, for instance?
Hope to see more Live Coding session from your channel ..
WOW. Grate Tutorial ❤
That was pretty cool ❤️❤️❤️
I don’t normally follow without good cause. But I’m following you.
Thanks man. Very good examples. Make more videos please...
Nice work !😊
I like the way you do it!
Thank you very much!
Outstanding!
nice teaching.
Wonderfull job!
Thank you so much very help full
You are great
thanks alot
At 3:22, why not use request->validated() to pass only those fields which are being validated through request.
this is an old video, he uses validated() nowadays because of obvious security flaws
Thank you so much. I learned lot
man,you are awesome!!!!!
Thank you.
sir your videos are too gud and helpful , i even started your free course for beginners in laravel, and i m waiting if you will uplaod any course realted to vue and laravel api
Great tutorial
Just awesome
one question, if you are new to this kind of project how do you know, that there is a service and an observer if you don't reference it in the controller?
Well, a lot of things may be outside of controllers, it's not only in the controllers you should look, you need to research all folders to understand how it is structured.
@@PovilasKorop yes, im still a beginner in laravel, but what it is very practical to me is to follow the view controller model, clearly defined in the routes/web. I hope to get more pro soon, :)
@@Paltibenlaish this isnt specific to laravel btw - other frameworks even languages you should aim to do coding like this..
Thank you! Great example I do the same in my codebase!
Hi and thanks for this video.
It's great. Thanks a lot
what if I want to update my post in other place but without sending the email?
you are the best
Thanks for the magic!
it is amazing, good video
Thanks!
Oh my god ... amazing tutorial
Note to Viewers: please read comments as well for explanation and more helpful information.
this video make me understand how to refactor my controller
You are great auosome like a magik❤💥💥
amazing tutorial!!, thanks
Ekach number na bhai
Awesome!
well, does it work for all the version ?
in 41st line of the original code, there is $words_count(), which i think should be $words_count. is it?
can i use a custom method name on my controller and have my observer listen to that method
You couldn't call observer in your postController, so how update method knows about observer?
i am using maatwebsite excel package, is there a way to import data and check validation on some specific fields, if any record fails to match validation, record the whole rows in a report excel file with the error message or red color in that field text which are not proper (the reason why validation failed) and then finally after full import have and option to download error excel file. So that we can correct the fields and upload that file again.Do you have any tutorial like this.
I will be highly thankful if you guide me how to do this, i have tried to read the maatwebsite excel package documentation, but it is not very much clear to me.
hi guys, great material here.
I need to make a functionality to take a csv as a request and update multiple tables,
how would be the correct way to afront this in laravel,??
(-the validation of the csv -creating records in many database and sending a response )
There's no one "correct" way. It depends on the complexity of your CSV, what kind of validation you need, and what you need to do after validation errors or after creating records. On each of the steps, there may be an error and you need to handle it in your way. You won't get such an answer in a simple TH-cam comment.
@@PovilasKorop haha, right, thank you for your answer, really looking forward for more of your amazing videos :)
hello, lately I've been watching your videos a lot. many good things i've learn from you. thank you so much.
but I have a question how to prevent race conditions when using observers or event listeners or services
do you use lockForUpdate method? please make video about lockForUpdate, rollback related with observers, event listener, and services. thank you.
Great stuff, It would be better if you have automated tests and for each modification you do, run the tests.
Yes, it would be better.