Skip to content

Variable inside tap #819

Answered by Gummibeer
prodv asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,
that's basic PHP you can use a variable in the function declaration.

$var = 'my special value';

activity()
   ->causedBy($userModel)
   ->tap(function(Activity $activity) use ($var) {
      $activity->my_custom_field = $var;
   })
   ->log();

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by prodv
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants