title: Laravel Queue Job gives error Model not found
body: <p>I have created the job file and I'm dispatching the mail through the controller using mailable it will create the entry in job table but after the few seconds it will transfer the record into the failed_jobs table and gives error model not found</p>
  
  <p>Controller Dispatch method</p>
  
  <pre><code>if (!empty($emails) &amp;&amp; isset($result-&gt;email)) {
                  dispatch(new SendNotificationEmailJob($emails, $result, 'WarehouseAddUpdate', array($subject, $request['number'], 'add')));
          }
  </code></pre>
  
  <p>SendNotificationEmailJob Class</p>
  
  <pre><code>&lt;?php
  
  namespace App\Jobs;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Queue\InteractsWithQueue;
  use Illuminate\Contracts\Queue\ShouldQueue;
  use Illuminate\Foundation\Bus\Dispatchable;
  use Illuminate\Support\Facades\Mail;
  
  class SendNotificationEmailJob implements ShouldQueue
  {
      use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  
      protected $emails;
      protected $result;
      protected $mailClass;
      protected $data;
  
      /**
       * Create a new job instance.
       *
       * @return void
       */
      public function __construct($emails, $result, $mailClass, $data)
      {   
          $this-&gt;emails = $emails;
          $this-&gt;result = $result;
          $this-&gt;mailClass = 'App\Mail\\'.$mailClass;
          $this-&gt;data = $data;        
      }
  
      /**
       * Execute the job.
       *
       * @return void
       */
      public function handle()
      {           
          if ($this-&gt;result == null) {
              if (!empty($this-&gt;emails)) {            
                  $to = $this-&gt;emails[0];    
                  unset($this-&gt;emails[0]);
              }
          }else{
              if($this-&gt;result != null &amp;&amp; isset($this-&gt;result-&gt;email)){                
                  $to = $this-&gt;result-&gt;email;
                  if (($key = array_search($this-&gt;result-&gt;email, $this-&gt;emails)) !== false) {
                      unset($this-&gt;emails[$key]);
                  }            
              }
          }
  
          if (!empty($this-&gt;emails) &amp;&amp; isset($result-&gt;email)) { 
              $email = new $this-&gt;mailClass($this-&gt;data);           
              Mail::to($to)-&gt;cc($this-&gt;emails)-&gt;send($email);            
          }
  
          if (empty($emails) &amp;&amp; isset($result-&gt;email)) {
              $email = new $this-&gt;mailClass($this-&gt;data);
              Mail::to($to)-&gt;send($email);
          }        
      }
  }
  </code></pre>
  
  <p>Mailable Class</p>
  
  <pre><code>&lt;?php
  
  namespace App\Mail;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Mail\Mailable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Contracts\Queue\ShouldQueue;
  
  class WarehouseAddUpdate extends Mailable
  {
      use Queueable, SerializesModels;
  
      /**
       * The data object instance.
       *
       * @var data
       */
      public $subject;
  
      public $warehouse;
  
      public $type;
  
      public $oldstatus;
  
      public $newstatus;
  
      public $receiver;
  
  
      /**
       * Create a new message instance.
       *
       * @return void
       */
      public function __construct($data)
      {
          $this-&gt;subject = $data[0];
          $this-&gt;warehouse = $data[1];
          $this-&gt;type = $data[2];
          $this-&gt;oldstatus = $data[3] ?? null;
          $this-&gt;newstatus = $data[4] ?? null;
          $this-&gt;receiver = 'Manager';
      }
  
      /**
       * Build the message.
       *
       * @return $this
       */
      public function build()
      {
          return $this-&gt;markdown('mails.warehouseaddupdate')-&gt;subject($this-&gt;subject);
      }
  }
  </code></pre>
  
  <p>this is my SendNotificationEmail Class</p>
  
  <pre><code>&lt;?php
  
  namespace App\Jobs;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Queue\InteractsWithQueue;
  use Illuminate\Contracts\Queue\ShouldQueue;
  use Illuminate\Foundation\Bus\Dispatchable;
  use Illuminate\Support\Facades\Mail;
  
  class SendNotificationEmailJob implements ShouldQueue
  {
      use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  
      protected $emails;
      protected $result;
      protected $mailClass;
      protected $data;
  
      /**
       * Create a new job instance.
       *
       * @return void
       */
      public function __construct($emails, $result, $mailClass, $data)
      {   
          $this-&gt;emails = $emails;
          $this-&gt;result = $result;
          $this-&gt;mailClass = 'App\Mail\\'.$mailClass;
          $this-&gt;data = $data;        
      }
  
      /**
       * Execute the job.
       *
       * @return void
       */
      public function handle()
      {           
          if ($this-&gt;result == null) {
              if (!empty($this-&gt;emails)) {            
                  $to = $this-&gt;emails[0];    
                  unset($this-&gt;emails[0]);
              }
          }else{
              if($this-&gt;result != null &amp;&amp; isset($this-&gt;result-&gt;email)){                
                  $to = $this-&gt;result-&gt;email;
                  if (($key = array_search($this-&gt;result-&gt;email, $this-&gt;emails)) !== false) {
                      unset($this-&gt;emails[$key]);
                  }            
              }
          }
  
          if (!empty($this-&gt;emails) &amp;&amp; isset($result-&gt;email)) { 
              $email = new $this-&gt;mailClass($this-&gt;data);           
              Mail::to($to)-&gt;cc($this-&gt;emails)-&gt;send($email);            
          }
  
          if (empty($emails) &amp;&amp; isset($result-&gt;email)) {
              $email = new $this-&gt;mailClass($this-&gt;data);
              Mail::to($to)-&gt;send($email);
          }        
      }
  }
  </code></pre>
  
  <p>The error I found in DB failed_jobs table</p>
  
  <blockquote>
    <p>Illuminate\Database\Eloquent\ModelNotFoundException: No query results
    for model [App\Model\V1\User]. in
    /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:416
    Stack trace:</p>
    
    <h1>0 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(54):</h1>
    
    <p>Illuminate\Database\Eloquent\Builder->firstOrFail()</p>
    
    <h1>1 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php(41):</h1>
    
    <p>App\Jobs\SendNotificationEmailJob->getRestoredPropertyValue(Object(Illuminate\Contracts\Database\ModelIdentifier))</p>
    
    <h1>2 [internal function]: App\Jobs\SendNotificationEmailJob->__wakeup()</h1>
    
    <h1>3 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(42):</h1>
    
    <p>unserialize('O:33:"App\Jobs\...')</p>
    
    <h1>4 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(76):</h1>
    
    <p>Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob),
    Array)</p>
    
    <h1>5 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(320):</h1>
    
    <p>Illuminate\Queue\Jobs\Job->fire()</p>
    
    <h1>6 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(270):</h1>
    
    <p>Illuminate\Queue\Worker->process('database',
    Object(Illuminate\Queue\Jobs\DatabaseJob),
    Object(Illuminate\Queue\WorkerOptions))</p>
    
    <h1>7 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(114):</h1>
    
    <p>Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob),
    'database', Object(Illuminate\Queue\WorkerOptions))</p>
    
    <h1>8 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101):</h1>
    
    <p>Illuminate\Queue\Worker->daemon('database', 'default',
    Object(Illuminate\Queue\WorkerOptions))</p>
    
    <h1>9 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85):</h1>
    
    <p>Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')</p>
    
    <h1>10 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()</h1>
    
    <h1>11 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29):</h1>
    
    <p>call_user_func_array(Array, Array)</p>
    
    <h1>12 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87):</h1>
    
    <p>Illuminate\Container\BoundMethod::Illuminate\Container{closure}()</p>
    
    <h1>13 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31):</h1>
    
    <p>Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application),
    Array, Object(Closure))</p>
    
    <h1>14 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Container/Container.php(549):</h1>
    
    <p>Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application),
    Array, Array, NULL)</p>
    
    <h1>15 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Console/Command.php(183):</h1>
    
    <p>Illuminate\Container\Container->call(Array)</p>
    
    <h1>16 /var/www/html/smartcgd/vendor/symfony/console/Command/Command.php(252):</h1>
    
    <p>Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Illuminate\Console\OutputStyle))</p>
    
    <h1>17 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Console/Command.php(170):</h1>
    
    <p>Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Illuminate\Console\OutputStyle))</p>
    
    <h1>18 /var/www/html/smartcgd/vendor/symfony/console/Application.php(946):</h1>
    
    <p>Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
    
    <h1>19 /var/www/html/smartcgd/vendor/symfony/console/Application.php(248):</h1>
    
    <p>Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand),
    Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
    
    <h1>20 /var/www/html/smartcgd/vendor/symfony/console/Application.php(148):</h1>
    
    <p>Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
    
    <h1>21 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Console/Application.php(88):</h1>
    
    <p>Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
    
    <h1>22 /var/www/html/smartcgd/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121):</h1>
    
    <p>Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput),
    Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
    
    <h1>23 /var/www/html/smartcgd/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput),</h1>
    
    <p>Object(Symfony\Component\Console\Output\ConsoleOutput))</p>
    
    <h1>24 {main}</h1>
  </blockquote>