'List Document Job', 'message' => 'You have successfully submit a job to list documents' ]; } /** * @param Request $request * @return JsonResponse */ public function logic(Request $request) : JsonResponse { $jobId = uniqid(); $user = Auth::user(); $userInfo = (object) [ 'email' => $user->email, 'type' => $user->type, ]; $listGenericJobObject = new ListGenericJobObject( $request->fullUrl(), $request->all(), $jobId, $userInfo ); ListDocuments::dispatch($listGenericJobObject); //cief todo: remove comments // // Create your job instance with delay, so we can back here within delay and take control in our hands. // $job = new ListDocuments($listGenericJobObject); // $job->delay(now()->addSeconds(5)); // // Dispath your job with our custom_dispatch helper. This will return job id from jobs table // // $jobId = $this->custom_dispatch($job); $result = []; $result['job_id'] = $jobId; return $this->response(['data' => $result]); } //cief todo: no longer need jobId // function custom_dispatch($job): int { // return app(\Illuminate\Contracts\Bus\Dispatcher::class)->dispatch($job); // } }