This is a simplified version of what I'm planning to do,
This Transaction is set to retry 5 times for example.
How can I access the attempt number from inside transaction?
DB::transaction(function ()
{
$number = 1;
if($ATTEMPT_NUMBER > 1){ // <-- How do I know attempt number? (e.g. #2 of 5 attempts)
$number += $ATTEMPT_NUMBER;
}
DB::update("update table set something = {$number}");
//... other DB stuff here
}, 5); // <-- 5 Attempts
I've tried:
$counter = 0;
DB::transaction(function () use ($counter)
{
$number = 1 + $counter++;
DB::update("update table set something = {$number}");
}, 5);
But it doesn't work.