1. Go to this page and download the library: Download lenorix/laravel-job-status library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lenorix / laravel-job-status example snippets
return [
/**
* Days to keep job trackers in the database before to be prunable.
*/
'prune_days' => env('JOB_STATUS_PRUNE_DAYS', 30),
];
use Lenorix\LaravelJobStatus\Traits\Trackable;
class YourJob implements ShouldQueue
{
use Queueable;
use Trackable; // Add this trait to your job.
public function handle()
{
// Optional, only if you want to get result with the tracker.
// It must serialize to JSON well.
$this->setResult(...);
}
}
$tracker = YourJob::dispatchWithTrack(...)
->afterResponse()
...
/// Get tracker to have a way to know when it's done.
->getJob()
->tracker();
$tracker->id; // Get the tracker ULID to check it in another request.
if ($tracker->isSuccessful()) {
...
}
if ($tracker->isFailed()) {
...
}
if ($tracker->isPending()) {
...
}
$tracker->result; // Get the result of the job, or null if not set.
use Lenorix\LaravelJobStatus\Facades\JobStatus;
$tracker = JobStatus::of($ulid);