protected function batchStatus(): Attribute
{
return Attribute::make(
get: function (mixed $value, array $attributes) {
$batch = $this->getBatch(); //All this does is check for a batch ID and if it is present, retrieve the batch from Laravel's Bus as defined in the docs
if (!$batch) {
return 'No Batch Found';
} else {
if($batch->finished()) { return 'Finished'; }
elseif($batch->cancelled()) { return 'Cancelled'; }
elseif($this->inProgress) { return 'In Progress'; }
elseif (!$batch->finished() && $batch->failedJobs > 0) { return 'Failed'; }
elseif (!$batch->finished() && $batch->pendingJobs > 0) { return 'Waiting'; }
else { return 'Unknown Status'; }
}
},
);
}
protected function batchStatus(): Attribute
{
return Attribute::make(
get: function (mixed $value, array $attributes) {
$batch = $this->getBatch(); //All this does is check for a batch ID and if it is present, retrieve the batch from Laravel's Bus as defined in the docs
if (!$batch) {
return 'No Batch Found';
} else {
if($batch->finished()) { return 'Finished'; }
elseif($batch->cancelled()) { return 'Cancelled'; }
elseif($this->inProgress) { return 'In Progress'; }
elseif (!$batch->finished() && $batch->failedJobs > 0) { return 'Failed'; }
elseif (!$batch->finished() && $batch->pendingJobs > 0) { return 'Waiting'; }
else { return 'Unknown Status'; }
}
},
);
}