Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusjunges committed Jan 30, 2024
1 parent 278d207 commit 0c9c181
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
15 changes: 0 additions & 15 deletions docs/advanced-usage/1-extending-the-tracked-job-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,10 @@ use Junges\TrackableJobs\Contracts\TrackableJobContract;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(TrackableJobContract::class, YourCustomModel::class);
}

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}
```

4 changes: 2 additions & 2 deletions docs/usage/1-tracking-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ProcessPodcastJob implements ShouldQueue
```


This trait provides 3 methods to your job: `__construct`, `failed` and `middleware`. It also adds a `model` public property to the job class.
This trait provides 3 methods to your job: `__construct`, `failed` and `middleware`.
If you want to override any of the methods, you must copy and paste (because you can't use `parent` for traits) the content of each one inside your class,
so this package still work as intended.

Expand Down Expand Up @@ -59,7 +59,7 @@ class ProcessPodcastJob implements ShouldQueue

public function __construct(Podcast $podcast)
{
$this->__baseConstruct($podcast);
$this->__baseConstruct();

// Add your code here.
}
Expand Down
23 changes: 21 additions & 2 deletions docs/usage/2-tracking-job-chains.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ It's a nice, fluent way of saying "Run this jobs sequentially, one after the pre

If you have a task which takes some steps to be completed, you can track the job chain used to do that and know the
status for each job.

If you are releasing a new podcast, for example, and it has to be optimized, compressed and released, you can track
this steps by adding a `steps` relationship to your `Podcast` model:
this steps by following two steps:

1 - Add a `steps` relationship to your `Podcast` model:

```php
public function steps()
Expand All @@ -28,7 +31,23 @@ public function steps()
}
```

Now, you can have the status of each job that should be processed to release your podcast:
2 - Override the `trackableType` and `trackableKey` methods provided by the `Trackable` trait, so this package will track the jobs
and automatically relate it to the Podcast you are working on:

```php
public function trackableKey(): ?string
{
return (string) $this->podcast->id;
}

public function trackableType(): ?string
{
return $this->podcast->gerMorphClass();
}
```

This will store the `id` and type of your podcast in the `tracked_jobs` table. Then, it will be used to retrieve all tracked jobs that were
related to that podcast:

```php
$steps = Podcast::find($id)->steps()->get();
Expand Down

0 comments on commit 0c9c181

Please sign in to comment.