1. Go to this page and download the library: Download codeldev/laravel-job-log 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/ */
use CodelDev\LaravelJobLog\Models\LaravelJobLog;
use CodelDev\LaravelJobLog\Enums\LaravelJobRunStatusEnum;
// Get all logs
LaravelJobLog::all();
// Filter by status
LaravelJobLog::query()
->where('status', LaravelJobRunStatusEnum::SUCCEEDED)
->get();
LaravelJobLog::query()
->where('status', LaravelJobRunStatusEnum::FAILED)
->get();
LaravelJobLog::query()
->where('status', LaravelJobRunStatusEnum::RUNNING)
->get();
// Filter by job class
LaravelJobLog::query()
->where('job', 'App\\Jobs\\MyJob')
->get();
// Filter by queue
LaravelJobLog::query()
->where('queue', 'default')
->get();
// Jobs from the last 24 hours
LaravelJobLog::query()
->where('started_at', '>=', now()->subDay())
->get();
// Slow jobs (over 1 second)
LaravelJobLog::query()
->where('duration_ms', '>', 1000)
->orderBy('duration_ms', 'desc')
->get();
// Failed jobs with exception details
LaravelJobLog::query()
->where('status', LaravelJobRunStatusEnum::FAILED)
->with('failedJob')
->get();
// Paginate results
LaravelJobLog::query()
->orderBy('created_at', 'desc')
->paginate(15);
use CodelDev\LaravelJobLog\Models\LaravelJobLog as BaseJobLog;
class JobLog extends BaseJobLog
{
public function scopeFailed($query)
{
return $query->where('status', LaravelJobRunStatusEnum::FAILED);
}
}