Queue, Events and Broadcasting

QUEUE_CONNECTION=sync
QUEUE_CONNECTION=database
php artisan queue:table // creates job table migration
php artisan migrate // migrate your database
php artisan make:job SendInvoiceEmail // create new job
class SendInvoiceEmail implements ShouldQueue{  use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;  // use Job’s constructor as an opportunity to send your payload to    the jobpublic function __construct($payload){  $this->payload = $payload;}//public function handle(){  // Email sending login goes here  // you can access $this->payload}

// now this will be queued on background thread
SendInvoiceEmail::dispatch($payload);

Pusher and Queues:

class SendInvoiceEmailSent implements ShouldBroadcast{use Dispatchable, InteractsWithSockets, SerializesModels;public function __construct($payload){$this-> payload = $payload;}public function broadcastOn(){return new PrivateChannel(‘temperature-reading.’.$this->attachedDeviceId);}
SendInvoiceEmailSent::dispatch($payload);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store