Just released a short video, explaining a topic called Dependency Injection. I’ve noticed that it’s quite hard to understand for junior developers, but in reality it’s easy when you see the example.
So, probably the most simple example is Laravel Notifications system, where you may want to have some internal variable to add to your email/SMS notification, but you have to pass them as parameters to the class. That’s a typical example of dependency injection – see how we’re passing $user variable here.
class Hello extends Notification
public function __construct(User $user)
$this->user = $user;
public function toMail($notifiable)
return (new MailMessage)
->line('Hi ' . $this->user->name . ' ('.$this->user->email.')')
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
See video below for more explanation.
The post Dependency Injection in Laravel: Notifications Example appeared first on Laravel Daily.
more link ADS
Smart Retail, Smart Agriculture, Smart supply Chain, Smart Health, Smart energy, Smart City
Blockchain, bitcoin, ethereum, blockchain technology, cryptocurrencies
Information Security, latest Hacking News, Cyber Security, Network Sec
Information Security, latest Hacking News, Cyber Security, Network Security
Blog! Development Software and Application Mobile
Development apps, Android, Ios anh Tranning IT, data center, hacking
Car News, Reviews, Pricing for New & Used Cars, car reviews and news, concept cars
Travel Blog is a unique free online travel diary for travellers across the world.