Skip to content

viicslen/laravel-trackable-tasks

Repository files navigation

Laravel Trackable Tasks

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation

You can install the package via composer:

composer require viicslen/laravel-trackable-tasks

You can publish and run the migrations with:

php artisan vendor:publish --tag="trackable-tasks-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="trackable-tasks-config"

This is the contents of the published config file:

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,
    ],
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="laravel-trackable-tasks-views"

Usage

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();
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages