Events In Laravel | How To Use Events | Listeners In Laravel | How to add Newsletters

  Рет қаралды 32,681

Code With Dary

Code With Dary

Күн бұрын

This video will learn you how to use events and listeners in Laravel. An event is basically a notification that something has taken place in your application. On the other hand, you also want to listen to your event, and that can be done with a listener.
Resources
- Patreon: www.patreon.com/user?u=30307830
- Instagram: / codewithdary
- Twitter: / codewithdary
Get up to 1 Month Free Hosting by using code "DARY15" and get $15 free hosting credit.
www.cloudways.com/en/?id=918573
Cloudways offers peace of mind and flexibility so you can focus on growing your business and reaching new milestones instead of dealing with server management. With Cloudways, you get an optimized stack, managed servers, backups, staging environment, integrated Git, pre-configured, Composer, 24/7 support, and the choice of five cloud providers: AWS, DigitalOcean, Linode, Google Cloud, and Vultr.
Laravel 8 & TailwindCSS repo
github.com/codewithdary/larav...
Coding Gear
- MacBook Pro: amzn.to/3qTMnGi
- Dell XPS: amzn.to/3Atp7Cm
- LG 34WN650-W: amzn.to/3G0XMbS
- Magic Trackpad 2: amzn.to/3Arp2ir
- Magic Mouse 2: amzn.to/346k5zC
- NAS: amzn.to/3rFf60U
- Sandisk SSD: amzn.to/3fNHcBB
- Rain Design Stand: amzn.to/3GTMeZ5
Recording Gear
- Rode NT-USB [Start]: amzn.to/3ApApXY
- Shure SM7B [Advanced]: amzn.to/3Arj5lv
- Rode PSA1: amzn.to/32pMCQ5
- Focusrite Scarlett 2i2: amzn.to/3FYZD0t
- XLR to XLR: amzn.to/3qVm2rC
Timestamps
0:00 Introduction
02:01 Sponsor of today’s video: Cloudways
02:38 Setting up the view, controller & route
07:47 Newsletter migration
09:34 Creating our Event & Listener
17:51 How to register the Event & Listener
▬▬▬
#cloudhosting #managedhosting #cloudways #laravel

Пікірлер: 88
@codewithdary
@codewithdary 2 жыл бұрын
LETS CONNECT THROUGH INSTAGRAM. www.Instagram.com/codewithdary
@alnahian2003
@alnahian2003 Жыл бұрын
It was super exciting to see how the event and listener works in laravel. I was kinda overwhelmed while reading the docs, but now the basics of events & listener is clear to me! WohHoo! Thanks Dary
@codewithdary
@codewithdary Жыл бұрын
Love to hear that, thank you Al Nahian!
@LEXUANPHAT
@LEXUANPHAT Жыл бұрын
Hi, I'm Vietnamese, I'm starting to self-study Laravel and I found your KZbin. I found your instructions very detailed, thank you for the lesson is very useful. Because I'm not good at English, I used google translate to support. If the wording is not appropriate, please forgive.
@codewithdary
@codewithdary Жыл бұрын
Hi Le Xuan, self-study is the best ;)
@abdulrafay1509
@abdulrafay1509 2 жыл бұрын
Nice vid bro! No one, literally no one, not a single soul! Backend devs: That's a pretty nice looking form field even though it's coming from me! :D
@codewithdary
@codewithdary 2 жыл бұрын
Hahahahahaa!
@hamayoonyousafi555ATgmail
@hamayoonyousafi555ATgmail 2 жыл бұрын
GREAT VIDEO! thank you so much Code With Dary.
@codewithdary
@codewithdary 2 жыл бұрын
You're so welcome!
@asim-gandu-phenchod
@asim-gandu-phenchod 2 жыл бұрын
Amazing content. Hats of to you Dary
@codewithdary
@codewithdary 2 жыл бұрын
Thank you buddy!
@GoTechAcademy
@GoTechAcademy 2 жыл бұрын
I like watching your tutorials. you are so intelligent.
@codewithdary
@codewithdary 2 жыл бұрын
You are too man! :) Thank you.
@Rasheedadedamola
@Rasheedadedamola 3 жыл бұрын
Thank. keep it coming!!
@codewithdary
@codewithdary 3 жыл бұрын
Will do Rasheed!
@TrikNgonlen
@TrikNgonlen 3 жыл бұрын
Damn! It's awesome tutorial...I love it...thank you so much... 🙏
@codewithdary
@codewithdary 3 жыл бұрын
Thank you for watching! :)
@ugochukwuekwueme575
@ugochukwuekwueme575 2 жыл бұрын
What of saving the data using controller class, and then using Laravel notification on the listener class? Make sense?
@muaf8374
@muaf8374 2 жыл бұрын
Yeah I like this kind of content. Educational and simple
@codewithdary
@codewithdary 2 жыл бұрын
Thank you so much :)
@abdallakaram5376
@abdallakaram5376 2 жыл бұрын
amazing Dary
@codewithdary
@codewithdary 2 жыл бұрын
Thank you Abdalla! :)
@abdulsalamghadeer6023
@abdulsalamghadeer6023 2 жыл бұрын
Can i use event to send notifications like user follow another user but not in email is there another way to make notification appear on user profile view؟
@yakhyomus
@yakhyomus 2 жыл бұрын
Thank you!
@codewithdary
@codewithdary 2 жыл бұрын
You're welcome!
@timshen5250
@timshen5250 Жыл бұрын
Is "event" async call like queue?
@writingbig
@writingbig Жыл бұрын
Dary, you mentioned (15:10) that you won't use Eloquent inside the handle() of the listener. Is there a reason why you preferred DB query over there?
@emmanuelboniface2660
@emmanuelboniface2660 Жыл бұрын
thank you Code with Dary, this your video was helpful
@codewithdary
@codewithdary Жыл бұрын
Love to help Emmanuel!
@vooDOO6625
@vooDOO6625 2 жыл бұрын
Very clear exlanation. Nice
@codewithdary
@codewithdary 2 жыл бұрын
Thank you Reuben!
@TheWaqaspuri
@TheWaqaspuri 2 ай бұрын
so lovely
@vuviy1711
@vuviy1711 2 жыл бұрын
great content!!!
@codewithdary
@codewithdary 2 жыл бұрын
Thank you so much! :)
@sithumdasantha3147
@sithumdasantha3147 3 жыл бұрын
Keep it up Bro ❤
@codewithdary
@codewithdary 3 жыл бұрын
Thank you, I will bro!!
@nicolegeorge8659
@nicolegeorge8659 2 жыл бұрын
This is a nice video bro , in my opinion using events and listeners is more of a long process …. There are shorter ways to do it with the controller and optimize time ! What do you think? Nice video btw ✅
@carlosf.2927
@carlosf.2927 Жыл бұрын
is that observer design pattern, basically?
@rohansinghrawat5676
@rohansinghrawat5676 2 жыл бұрын
i am sending mails for multiple users using event listener but the problem is firstly my listener is executing and after that it is returrning me response so it is not helping me in any way ? any idea where i am doing wrong or any thing i am missing please help me ??
3 жыл бұрын
Thanks for the tutorial. It's very clear! My only question is when should we trigger the e-mail sending through the event instead of doing it directly within the controller?
@codewithdary
@codewithdary 3 жыл бұрын
You should add it inside the handle() method of your Listener!
@bewellegoist
@bewellegoist 2 жыл бұрын
I guess, it is better to send an email via event because this kind of task may require some time to process. I mean, saving data to DB via listener - is kinda weird, there is a repository for that, but handling logs and email seems appropriate
@peterpardo4138
@peterpardo4138 2 жыл бұрын
amazing
@codewithdary
@codewithdary 2 жыл бұрын
Thanks 😄
@jseh_
@jseh_ 2 жыл бұрын
very clear
@codewithdary
@codewithdary 2 жыл бұрын
Glad to hear that
@hernanmartinezreumann3279
@hernanmartinezreumann3279 3 жыл бұрын
Thanks Dary! Great video!! What other kind of things should be managed by Events & Listeners? It is like they do the job of the Controllers.
@codewithdary
@codewithdary 3 жыл бұрын
Think about emailing a user when they subscribe to your newsletter of when they buy a product. You can fire an event to send them either the confirmation or just a thank you message. Or even a better example: send a discount code to customers that buy products in let's say 5 days from the purchase!
@hernanmartinezreumann3279
@hernanmartinezreumann3279 3 жыл бұрын
@@codewithdary Thanks for your response!!
@piyushkumardongre5873
@piyushkumardongre5873 3 жыл бұрын
@@codewithdary Hi, How can we pass more info into the Event. Like we want to show in the received email, the Name of Person, email address etc who has subscribed.
@lijinv674
@lijinv674 3 жыл бұрын
Nice bro
@codewithdary
@codewithdary 3 жыл бұрын
Thanks!!
@owfprem1754
@owfprem1754 3 жыл бұрын
Very clear explanation, awesome ! Just one question, why store the data thru the event instead of controller ?
@paweliszka44
@paweliszka44 2 жыл бұрын
Same question here, as far as i understand "event" is sth that was done in past an is stored in som kind of DB
@rohansinghrawat5676
@rohansinghrawat5676 2 жыл бұрын
@@paweliszka44 it is just a example so you can store it in controller instead of listener
@broouklynco.tutorials5606
@broouklynco.tutorials5606 Жыл бұрын
hey, love your vscode look, can you share your extensions and configuration? Thank you in advance!
@codewithdary
@codewithdary Жыл бұрын
Hi, here's a video where I setup VS code: kzbin.info/www/bejne/gXK4qZqLq6hoZ5Y And I use Material Theme (I think palenight) for my theme :)
@GergelyCsermely
@GergelyCsermely 3 жыл бұрын
Thanks
@codewithdary
@codewithdary 3 жыл бұрын
Welcome!!
@ifeanyinnaemego
@ifeanyinnaemego Жыл бұрын
How can I attached their details like name in the sent email
@codewithdary
@codewithdary Жыл бұрын
Through the user object!
@MrSonicastra
@MrSonicastra 3 жыл бұрын
Nice never heard about these terms, nice to see im gonna add this to my blog website also thanks to one of your video's! Thanks for sharing, Dary. 👌
@codewithdary
@codewithdary 3 жыл бұрын
My pleasure Angelino! Thanks for joining Patreon :)
@geoffrey6420
@geoffrey6420 2 жыл бұрын
Good work. What extension are you using for laravel in visual studio code?
@codewithdary
@codewithdary 2 жыл бұрын
Thank you. I recently created a video where I setup VSCode: kzbin.info/www/bejne/gXK4qZqLq6hoZ5Y&t
@geoffrey6420
@geoffrey6420 2 жыл бұрын
@@codewithdary Thanks. I shall watch it.
@shailu016hai6
@shailu016hai6 3 жыл бұрын
💃
@codewithdary
@codewithdary 3 жыл бұрын
👌
@Ramziddin_Rustamovv
@Ramziddin_Rustamovv 2 жыл бұрын
🤝👍
@codewithdary
@codewithdary 2 жыл бұрын
👌🏽
@augischadiegils.5109
@augischadiegils.5109 Жыл бұрын
nicee
@codewithdary
@codewithdary Жыл бұрын
Thanks Augis!!
@fraazwas5915
@fraazwas5915 3 жыл бұрын
✨✨✨✨
@codewithdary
@codewithdary 3 жыл бұрын
:)
@timothybeldeniza2548
@timothybeldeniza2548 2 жыл бұрын
Hi, How can we pass more info into the Event. Like we want to show in the received email, the Name of Person, email address etc who has subscribed.
@codewithdary
@codewithdary 2 жыл бұрын
You should be passing them in the constructor, and when you call the Event from your Controller, you should be passing the variables as parameters :)
@timothybeldeniza2548
@timothybeldeniza2548 2 жыл бұрын
@@codewithdary Thank you so much !
@timothybeldeniza2548
@timothybeldeniza2548 2 жыл бұрын
Good day Dary, may i ask, how can i use Queues here in your Event and Listener, where do i put the dispatch method, in listener class? Thanks
@Ramziddin_Rustamovv
@Ramziddin_Rustamovv 2 жыл бұрын
Hi , bro i have questions aut of topic . Can you make a video which is about working as a frelancer . As a laravel developer , i am student at the international education programme . In the field of computer science ... It would be better , i will wait .👍👍🙂
@codewithdary
@codewithdary 2 жыл бұрын
That sounds like a interesting video :)
@fancyAlex1993
@fancyAlex1993 Жыл бұрын
The documentation really needs work with Observers, Events and Listeners
@codewithdary
@codewithdary Жыл бұрын
Definitely agree with you, especially because those topics are quite difficult as well.
@vrj93
@vrj93 2 жыл бұрын
Not working
@codewithdary
@codewithdary 2 жыл бұрын
It should be :)
@vrj93
@vrj93 2 жыл бұрын
@@codewithdary I forgot to include path in Eventserviceprovider. Working now. Thanks...
@cesarperalta4959
@cesarperalta4959 2 жыл бұрын
Jesus.... half of the tutorial was non event related
@codewithdary
@codewithdary 2 жыл бұрын
Am I the only one seeing timestamps in the video? :)
How To Use Broadcasting In Laravel | What is Broadcasting in Laravel?
21:28
Get started with Laravel events and listeners
15:37
Andrew Schmelyun
Рет қаралды 19 М.
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,7 МЛН
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 25 МЛН
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 210 МЛН
Laravel Security: Top 7 Mistakes Developers Make
11:16
Laravel Daily
Рет қаралды 82 М.
09 - Events & Listeners
11:01
Laravel
Рет қаралды 22 М.
Laravel Advanced - Task Scheduling - CRON Job
16:26
Laratips
Рет қаралды 61 М.
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,7 МЛН