|
16 | 16 |
|
17 | 17 | use Illuminate\Contracts\Queue\Job;
|
18 | 18 | use Illuminate\Support\Carbon;
|
| 19 | +use Illuminate\Support\Collection; |
19 | 20 | use Illuminate\Support\Facades\App;
|
20 | 21 | use Illuminate\Support\Facades\Auth;
|
21 | 22 | use Illuminate\Support\Facades\Event;
|
|
25 | 26 | use Konekt\History\Contracts\JobStatus;
|
26 | 27 | use Konekt\History\Contracts\SceneResolver;
|
27 | 28 | use Konekt\History\Contracts\TrackableJob;
|
| 29 | +use Konekt\History\Events\TrackableJobAdvanced; |
28 | 30 | use Konekt\History\Events\TrackableJobCompleted;
|
29 | 31 | use Konekt\History\Events\TrackableJobCreated;
|
30 | 32 | use Konekt\History\Events\TrackableJobFailed;
|
@@ -122,7 +124,11 @@ public function getProgressMax(): int
|
122 | 124 |
|
123 | 125 | public function advance(int $steps = 1): void
|
124 | 126 | {
|
125 |
| - $this->model()?->advance($steps); |
| 127 | + if (null !== $model = $this->model()) { |
| 128 | + $model->advance($steps); |
| 129 | + |
| 130 | + Event::dispatch(new TrackableJobAdvanced($this->job)); |
| 131 | + } |
126 | 132 | }
|
127 | 133 |
|
128 | 134 | public function getProgress(): int
|
@@ -163,6 +169,11 @@ public function log(string $message, string $level = LogLevel::INFO, array $cont
|
163 | 169 | return $log;
|
164 | 170 | }
|
165 | 171 |
|
| 172 | + public function logs(): Collection |
| 173 | + { |
| 174 | + return $this->model()?->getLogs() ?? collect(); |
| 175 | + } |
| 176 | + |
166 | 177 | protected static function commonFields(TrackableJob $job): array
|
167 | 178 | {
|
168 | 179 | [$via, $scene] = static::sceneResolver()->get();
|
|
0 commit comments