Skip to content

Conversation

@afiqiqmal
Copy link

Propose helper function, dd_when, allowing conditional debugging with dd(). This function provides a simple way to invoke dd() based on a boolean condition.

Example Usage:

dd_when($user->isAdmin(), $user, 'Only admins can see this debug info');

Sample Use case:

Before

foreach($users as $user) {
      if ($user->dontHaveOrder()) {
            dd($user->id);
      }
     ....
}

After

foreach($users as $user) {
      dd_when($user->dontHaveOrder(), $user->id);
     ....
}

@afiqiqmal afiqiqmal closed this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant