PHP code example of ami-praha / laravel-db-queue-monitor

1. Go to this page and download the library: Download ami-praha/laravel-db-queue-monitor 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/ */

    

ami-praha / laravel-db-queue-monitor example snippets


AmiPraha\LaravelDbQueueMonitor\Providers\LaravelDbQueueMonitorProvider::class,

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use AmiPraha\LaravelDbQueueMonitor\Traits\LaravelDbQueueMonitor; // <---

class ExampleJob implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;
    use LaravelDbQueueMonitor; // <---

    public function handle()
    {
        // Save progress, if job driver supports
        $ffmpeg->on('progress', function ($percentage) {

            $this->queueProgress($percentage);
        });

        // Save data if finished. Must be type of array
        $this->queueData(['foo' => 'bar']);
    }
}

use AmiPraha\LaravelDbQueueMonitor\Models\Monitor;

$jobs = Monitor::ordered()->get();

foreach ($jobs as $job) {

    // Exact start & finish dates with milliseconds
    $job->startedAtExact();
    $job->finishedAtExact();
}

// Filter by Status
Monitor::failed();
Monitor::succeeded();

// Filter by Date
Monitor::lastHour();
Monitor::today();

// Chain Scopes
Monitor::today()->failed();

// Get parsed custom Monitor data

$monitor = Monitor::find(1);

$monitor->data; // Raw data string

$monitor->parsed_data; // JSON decoded data, always array

$ php artisan migrate