I need to be able to join an entry from Laravel's job_batches
table onto one of my own tables & model which contains reference to a batch ID.
I'd like to do this through the model using the hasOne
relationship but when I try to do this I'm getting an error:
Class 'App\Models\Illuminate\Support\Facades\Bus\Batch' not found
What am I missing here?
My model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
class CSVUploadSchedule extends Model
{
use SoftDeletes;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'csv_upload_schedules';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'csv_name',
'csv_path'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'processed_at' => 'datetime',
'start_processing_at' => 'datetime'
];
/**
* The relationships that should always be loaded.
*
* @var array
*/
protected $with = [
'batch'
];
/**
* Get the batch associated with the schedule.
*/
public function batch()
{
return $this->hasOne(Illuminate\Support\Facades\Bus\Batch::class, 'id','batch_id');
}
}