title: Can't pass Eloquent model to Laravel Job
body: <p>I'm following the documentation for Laravel to pass an Eloquent model to a Laravel Job. However, despite my best efforts, I can't pass the Eloquent model - it is always "undefined" or another weird error.</p>
  
  <p>This is for a Laravel 5.7 application, currently running on MacOS/Darwin, MySQL 5.5, and PHP 7.2. This job is launched from another job. I have one job which then dispatches many sub-jobs. </p>
  
  <pre><code>// From the Job itself
  public function __construct(\App\Course $courseToDB)
  {
      $this-&gt;courseToDB = $courseToDB;
  }
  
  public function handle(App\Course $courseToDB)
  {        
      Log::info($this-&gt;courseToDB);
  }
  // From where I am dispatching the job
  \App\Jobs\syncCourse::dispatch($courseToDB)-&gt;onConnection('database');
  </code></pre>
  
  <p>I expect that, when I dispatch the job with <code>$courseToDB</code> (an \App\Course model), the job will be able to pick that model up and, well, do things with it. The problem I have is that it will not pass the model to the job. Trying to use it even in the simplest logging scenario fails. </p>
  
  <p><strong>Update: My Model</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use Carbon\Carbon;
  
  class Course extends Model
  {
      protected $fillable = ['id', 'name', 'category_id', 'teacher_id', 'moodle_id', 'summary'];
  
      public function teacher() {
          return $this-&gt;belongsTo('App\Teacher');
      }
      public function category() {
          return $this-&gt;belongsTo('App\Category');
      }
      public function views() {
          return $this-&gt;morphMany(
              \App\view::class,
              'viewable'
          );
      }
  // A few other functions cut out (very simple one-liners)
  
  }
  </code></pre>
  
  <p><strong>Update: My Migration</strong></p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateCoursesTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('courses', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;integer('moodle_id');
              $table-&gt;integer('teacher_id');
              $table-&gt;integer('category_id');
              $table-&gt;longText('summary')-&gt;nullable();
              $table-&gt;timestamps();
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('courses');
      }
  }
  </code></pre>
  
  <p><strong>Update: My Job (syncCourse), which even when doing nothing fails</strong></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\Log;
  use App\Course;
  
  class syncCourse implements ShouldQueue
  {
      public $courseToDB;
  
      use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
      /**
       * Create a new job instance.
       *
       * @return void
       */
      public function __construct(Course $courseToDB)
      {
          //\App\Course $courseToDB
          $this-&gt;courseToDB = $courseToDB;
      }
  
      /**
       * Execute the job.
       *
       * @return void
       */
      public function handle()
      {        
  
      }
  }
  </code></pre>
  
  <p><strong>Update: From Terminal (when running)</strong></p>
  
  <pre><code>[2018-12-23 01:51:28][3891] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3891] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3892] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3892] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3893] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3893] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3894] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3894] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3895] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3895] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3896] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3896] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3897] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3897] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3898] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3898] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3899] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3899] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3900] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3900] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3901] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3901] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3902] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3902] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3903] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3903] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3904] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3904] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3905] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3905] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3906] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3906] Failed:     App\Jobs\syncCourse
  [2018-12-23 01:51:28][3907] Processing: App\Jobs\syncCourse
  [2018-12-23 01:51:28][3907] Failed:     App\Jobs\syncCourse
  </code></pre>
  
  <p>In my app, <code>dispatchSync</code> dispatches hundreds of <code>syncCourse</code> and passes an Eloquent model. Passing the Eloquent model is what is broken, because even if I do absolutely <em>nothing</em> with the passed model, it errors. Laravel.log has zero trace of an error.</p>
  
  <p><strong>UPDATE 2: After running Logging in Service Provider</strong></p>
  
  <p>After turning on the logging in the service provider, all of the syncCourse events just went unfinished. Now my <code>queue:work</code> looks like this:</p>
  
  <pre><code>[2018-12-23 02:10:41][5829] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5830] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5831] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5832] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5833] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5834] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5835] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5836] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5837] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5838] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5839] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5840] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5841] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5842] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5843] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5844] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5845] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5846] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5847] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5848] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5849] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5850] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5851] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5852] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5853] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5854] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5855] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5856] Processing: App\Jobs\syncCourse
  [2018-12-23 02:10:41][5857] Processing: App\Jobs\syncCourse
  </code></pre>
  
  <p>In the logs:</p>
  
  <pre><code>[2018-12-23 02:10:34] local.ERROR: database
  [2018-12-23 02:10:34] local.ERROR: Object of class Illuminate\Queue\Jobs\DatabaseJob could not be converted to string {"exception":"[object] (ErrorException(code: 0): Object of class Illuminate\\Queue\\J
  </code></pre>