title: Laravel Dispatch Intercept/Customize
body: <p>I basically want to do this: <a href="https://stackoverflow.com/questions/32907972/add-custom-field-to-laravel-queued-job-records">Add custom field to Laravel queued job records?</a></p>
  
  <p>However the top-voted answer there doesn't really address how to do this, rather it advocates for a work-around.</p>
  
  <p>I know in order to actually accomplish this I need to tap into the <code>dispatch</code> function. The issue is it isn't being called directly in my (in this case) event listener.</p>
  
  <p>According to <a href="https://laravel.com/docs/5.5/queues#dispatching-jobs" rel="nofollow noreferrer">this</a> and <a href="https://laravel.com/docs/5.5/helpers#method-dispatch" rel="nofollow noreferrer">this</a> <code>dispatch</code> is a global helper function. Where in the source code is this registered and how should I overwrite it in my event listener in order to run <code>handle()</code> (that which dispatch itself calls) in my <code>Job</code> class after a specified delay and yet be able to add additional entries/fields to the database?</p>
  
  <p>My prime reason for this is because:</p>
  
  <p>1). The job is sending a notificaiton via email.</p>
  
  <p>2). Emails should only go out after a delay IF the user hasn't logged in/been active during that delay.</p>
  
  <p>3). AND emails should only go out if that user doesn't have another email queued up since the first was dispatched, in which case the first should be consolidated and deleted into the second email.</p>
  
  <p>Therefore I need additional database fields in order to find, delete and modify entries in the jobs table.</p>
  
  <p>These ideas come from <a href="https://medium.com/@intercom/designing-smart-notifications-36336b9c58fb" rel="nofollow noreferrer">an article on Medium</a> which teaches that you don't want to spam users with emails/notifications and you need to consolidate/group/prioritize them and I'm trying to do this in Laravel.</p>
  
  <p>I believe it is possible in Laravel but I am unsure how to overwrite the functionality when <code>dispatch</code> is a global and I don't know from where it is invoked. The Laravel docs on <a href="https://laravel.com/docs/5.0/bus" rel="nofollow noreferrer">the Command Bus</a> don't go beyond Laravel 5.0.</p>
  
  <p><strong>Edit:</strong> I have to use Redis now, according to this (because I am getting that <code>beginTransaction()</code> error in my queue): </p>
  
  <p><a href="https://github.com/laravel/framework/issues/19242#issuecomment-302107155" rel="nofollow noreferrer">Redis Driver > Database Driver</a></p>
  
  <p>I think a model watcher would be best but I'm not sure if <code>Job</code> is an Eloquent model. I need something that will work consistently across database drivers.</p>