title: How to notify the user that a job has completed in Laravel?
body: <p>in Laravel, you can use <a href="https://laravel.com/docs/5.2/queues" rel="noreferrer">jobs</a> to execute tasks in a back-end queue while the rest of the application does other things. i have a job that is initiated by user input. immediately, through javascript, i give the user a notification that the job is being processed.</p>
  
  <p>i would like to be able to give a similar notification after the job has successfully completed.</p>
  
  <p>i am calling my job from within a model like this:</p>
  
  <pre><code>public function doSomething() {
      $job = new \App\Jobs\MyJob();
      app('Illuminate\Contracts\Bus\Dispatcher')-&gt;dispatch($job);
  }
  </code></pre>
  
  <p>and this is how my job headers look like:</p>
  
  <pre><code>class MyJob extends Job implements SelfHandling, ShouldQueue
  {
      use InteractsWithQueue, SerializesModels, Queueable;
      ...
  }
  </code></pre>
  
  <p>the model job call is actually triggered from a controller method:</p>
  
  <pre><code>public function getDoSomething($id) {
      $item = Item::findOrFail($id);
      $item-&gt;doSomething();
  
      return response()-&gt;json(true);
  }
  </code></pre>
  
  <p>which is handled by an AJAX call:</p>
  
  <pre><code>$.ajax({
      url: $(this).attr('href'),
      type: 'GET',
      dataType: 'json',
      success: $.proxy(function(result) {
          this.application.notification.showMessage('Job is being processed.');
      }, this),
      error: $.proxy(function(result) {
          console.error(result);
      }, this)
  });
  </code></pre>