PHP code example of viicslen / laravel-trackable-tasks

1. Go to this page and download the library: Download viicslen/laravel-trackable-tasks 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/ */

    

viicslen / laravel-trackable-tasks example snippets


return [
    'queue_listener' => ViicSlen\TrackableTasks\QueueListeners\DefaultListener::class,
    'model' => ViicSlen\TrackableTasks\Models\TrackedTask::class,
    'prunable_after' => 90,
    'database' => [
        'connection' => null,
        'table' => 'tracked_task',
    ],
    'events' => [
        'retrieved' => ViicSlen\TrackableTasks\Events\TrackableTaskRetrieved::class,
        'creating' => ViicSlen\TrackableTasks\Events\TrackableTaskCreating::class,
        'created' => ViicSlen\TrackableTasks\Events\TrackableTaskCreated::class,
        'updating' => ViicSlen\TrackableTasks\Events\TrackableTaskUpdating::class,
        'updated' => ViicSlen\TrackableTasks\Events\TrackableTaskUpdated::class,
        'saving' => ViicSlen\TrackableTasks\Events\TrackableTaskSaving::class,
        'saved' => ViicSlen\TrackableTasks\Events\TrackableTaskSaved::class,
        'deleting' => ViicSlen\TrackableTasks\Events\TrackableTaskDeleting::class,
        'deleted' => ViicSlen\TrackableTasks\Events\TrackableTaskDeleted::class,
        'restoring' => ViicSlen\TrackableTasks\Events\TrackableTaskRestoring::class,
        'restored' => ViicSlen\TrackableTasks\Events\TrackableTaskRestored::class,
        'force_deleting' => ViicSlen\TrackableTasks\Events\TrackableTaskForceDeleted::class,
        'trashed' => ViicSlen\TrackableTasks\Events\TrackableTaskTrashed::class,
        'replicating' => ViicSlen\TrackableTasks\Events\TrackableTaskReplicating::class,
        'exception_added' => ViicSlen\TrackableTasks\Events\TrackableTaskExceptionAdded::class,
        'status_updated' => ViicSlen\TrackableTasks\Events\TrackableTaskStatusUpdated::class,
    ],
];

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use ViicSlen\TrackableTasks\Concerns\TrackAutomatically;

class TestJobWithTracking implements ShouldQueue
{
    use InteractsWithQueue;
    use Queueable;
    use Dispatchable;
    use TrackAutomatically;

    public function handle(): void {
        $this->taskSetProgressMax(200);

        $this->taskIncrementProgress();

        sleep(1);
        $this->taskIncrementProgress(10);

        sleep(1);
        $this->taskIncrementProgress(20);

        sleep(1);
        $this->taskIncrementProgress(30);

        sleep(1);
        $this->taskFinishProgress();
    }
}
bash
php artisan vendor:publish --tag="trackable-tasks-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="trackable-tasks-config"
bash
php artisan vendor:publish --tag="laravel-trackable-tasks-views"