Replies: 1 comment 3 replies
-
I guess you are mentioning this because you are using the relation with magic call like |
Beta Was this translation helpful? Give feedback.
3 replies
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.
-
There's already
Relation::sole()
, but it isn't a modifier but executes the query, so it can't be used withwith()
, for example.Let's assume, we have a process with multiple steps. Within the first step, a relationship might return
null
, but will be set by the end of said step.In the subsequent steps, I want to eager load said model but there might be cases, where we get an exception like this:
Caution
Attempt to read property "name" on null
If I don't want to check this manually, maybe even in several separate places and don't want an accessor in the model, I can have a separate relationship:
This works, however, it would be even nicer, if there was an out-of-the-box modifier to achive this without manually instanciating the exception and setting the model like with
sole()
.Beta Was this translation helpful? Give feedback.
All reactions