I'm working on a Laravel Lumen project. My Lumen project is connected to my database where another Laravel project connects, I'm splitting the load by using Lumen here.
I've created a Job in Lumen and nested this in a directory called Reports inside my Jobs folder, but when running queue:work --queue=reports
I'm getting this error:
method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "App\Jobs\Reports\ConsolidateAverageConversions" of the object you are trying to operate on was loaded before unserialize() gets called or provide an autoloader to load the class definition
What am I missing in my Job?
<?php
namespace App\Jobs\Reports;
use App\Traits\Reports;
use App\Traits\Graphs;
use Carbon\Carbon;
class ConsolidateAverageConversions extends Job
{
use Reports, Graphs;
/**
* Create a new job instance.
*
* @return String
*/
public $queue = 'reports';
/**
* Chosen report
*/
public $report;
/**
* Chosen journey
*/
public $journey;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($report, $journey)
{
$this->report = $report;
$this->journey = $journey;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$from = Carbon::now()->subMonths(1)->startOfDay();
$to = Carbon::now()->endOfDay();
// the raw data
$conversions = $this->getAverageDailyConversionRate($from, $to, $this->journey);
// generate a chart
$graph = $this->createChart($conversions, [
'chart_name' => 'average_conversions',
'label' => 'date',
'metric' => 'conversion_rate'
]);
// create the report in our db
$this->createReport([
'charts' => $graph,
'report' => $conversions
], $this->report);
}
}