Add track jobs to mass store action
This commit is contained in:
parent
2ecdf6e362
commit
a755d63197
|
@ -3,6 +3,9 @@
|
||||||
namespace App\Invoice\Actions;
|
namespace App\Invoice\Actions;
|
||||||
|
|
||||||
use App\Invoice\Models\Invoice;
|
use App\Invoice\Models\Invoice;
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
@ -11,6 +14,7 @@ use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
class MassStoreAction
|
class MassStoreAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
|
@ -43,8 +47,19 @@ class MassStoreAction
|
||||||
|
|
||||||
public function asController(ActionRequest $request): JsonResponse
|
public function asController(ActionRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->handle($request->year);
|
$this->startJob($request->year);
|
||||||
|
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
return $jobState
|
||||||
|
->after('Zahlungen erstellt')
|
||||||
|
->failed('Fehler beim Erstellen von Zahlungen')
|
||||||
|
->shouldReload(JobChannels::make()->add('invoice'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ trait TracksJob
|
||||||
{
|
{
|
||||||
$jobId = Str::uuid();
|
$jobId = Str::uuid();
|
||||||
$jobState = WithJobState::make($jobId);
|
$jobState = WithJobState::make($jobId);
|
||||||
$this->jobState(...[$jobState, ...$parameters])->beforeMessage->dispatch();
|
tap($this->jobState(...[$jobState, ...$parameters])->beforeMessage, fn ($beforeMessage) => $beforeMessage && $beforeMessage->dispatch());;
|
||||||
$parameters[] = $jobId;
|
$parameters[] = $jobId;
|
||||||
static::dispatch(...$parameters);
|
static::dispatch(...$parameters);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue