Idea for lineIf method in SimpleMessage class #45576
Unanswered
crojasaragonez
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Method lineIf in class Illuminate\Notifications\Messages\SimpleMessage receives two params
Scenario:
let's imagine that the second parameter is an expensive operation, for instance
Invoice::where('expired_date', '>=' Carbon::today()))->count()
.Right now, no matter if the first parameter is false, the second operation will always get executed.
Proposal:
Allow the second parameter to be a callable and only run the code if the first parameter is true just like we do in the when method in our query builder.
$query->when(false, fn ($q) => $q->where(...))
Beta Was this translation helpful? Give feedback.
All reactions