Courses

Design Patterns in Laravel 11

Adapter: in Notifications and Filesystem

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Adapter pattern in Laravel Notifications system
- Implementation of multiple notification channels
- Filesystem adapters for different storage systems
- Seamless data transformation between different services

We don't even have to dig too deep for this next pattern. We have to look at Notifications in Laravel:

Notification

public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Link button', route('link'));
}

In this example, we've transformed our data to be compatible with the MailMessage class, which will be used to send emails. This is the adapter pattern in action! There are two layers to it:

  1. We are transforming our data to be compatible with the MailMessage class
  2. The MailMessage class transforming our data to be compatible with the email API

And all of that is done seamlessly without us even knowing about it! We don't have to worry about the email driver or what data it expects. We have to...

The full lesson is only for Premium Members.
Want to access all 17 lessons of this course? (72 min read)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord