packy
3 months ago

Re check if statment

Posted 3 months ago by packy

What is the best way to keep checking a condition until it is true? I know there is a while statement in PHP but was not sure if there is a better packaged way in Laravel.

Basically I am transcoding a video through AWS. I want the frontend to keep saying "Uploading" until I know the video is transcoded and saved in AWS and all info is in the database. The videos will be short, but still transcoding is not instant so if I do:

if ($job['Status'] == 'complete') {

                    $submission = new Submission();

                    $submission->email = $request->input('email');
                    $submission->original = config('filesystems.disks.s3.url') . $original_key;

                    $submission->save();

                    return response()->json([
                        'submission' => $submission,
                        'message' => 'Upload Successful. Good luck!!!!',
                        'job' => $job
                    ]);
}

This if statement will be false right away. But if I checked again every few seconds it will pass after a little bit. Is there a pulse type function to continue to run that if statement every X amount of time until it passes? Using a while seems to be hitting max_execution_time the limit.

Please sign in or create an account to participate in this conversation.