How do I return a value from a call to Laravel DB::transaction(function () use() { … } );

Actually the DB::transaction(...) returns whatever is returned from the callback.

So you could simplify it to:

 

$result = DB::transaction(function () {
  // ...logic here 
return someGetResult(); 
}); 
dd($result);

Leave a Comment

Your email address will not be published. Required fields are marked *