php - Laravel - Mailer Service? -


i'm bit of noob laravel i'm setting bug tracking system , have question how remove multiple instances of sending mails. let me show how i've got set currently:

public function store(usersrequest $request) {     $user = user::create($request->all());      mail::queue('emails.master', ['user' => $user], function($message) use ($user) {     $message->to('someone@somewhere.com')             ->subject('new user created');     });      return redirect('/users'); } 

so have method in controller creates new user in system, send mail out. i'd strip mail call out 1 line of code.

what's best way achieve this?

what i've found far, setting service handle - this: http://lukefair.com/create-a-mailer-service-with-laravel-and-a-basic-working-example-of-dependency-injection/

this seems idea noob brain , achieve need to. there better way creating service? making use of events perhaps (although, guess i'd still need service that)?

as said, i'm bit of laravel noob , haven't got these patterns , ways of doing things down yet.

any advice great. thanks!

the typical solution problems is, in laravel world @ least, create service provider. article linked fit looking do.

if want able access new mailer class globally can mail , request , of other familiar laravel facades, can create own , usable anywhere in application.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -