Can anyone provide an edge case when EloquentBuilder::__call should not return forwardDecoratedCallTo and ditch passthru? #56680
-
More details here: #56664 We are thinking of replacing (for our projects) forwardCallTo with forwardDecoratedCallTo in the eloquent builder's _call and make obsolete ![]() forwardDecoratedCallTo will return Eloquent Builder if the return of the function call from Query Builder is the same object as the Query Builder. protected function forwardDecoratedCallTo($object, $method, $parameters)
{
$result = $this->forwardCallTo($object, $method, $parameters);
return $result === $object ? $this : $result;
} |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
No one? @shaedrich |
Beta Was this translation helpful? Give feedback.
-
This actually makes sense because the current forwardCallTo will just return the raw result from the Query\Builder. That forces us to rely on $passthru to make sure some methods still return the Eloquent Builder, which feels like a workaround. |
Beta Was this translation helpful? Give feedback.
-
@Nabil-nl @shaedrich thank you. We merged the change in our framework. Question is, should we do it also in our crud/rest lib suite so whoever uses it can benefit RETROACTIVELY from this change? https://github.com/macropay-solutions/laravel-crud-wizard-free/pull/24/files |
Beta Was this translation helpful? Give feedback.
-
Yes, I think it’s worth applying the same change in the CRUD/REST suite too. That way users get the benefit retroactively and behavior stays consistent across the ecosystem. As long as it’s backward compatible, it should be a safe improvement. |
Beta Was this translation helpful? Give feedback.
-
@Nabil-nl @shaedrich how about this ![]() This would keep the global scopes applied to the passthru. |
Beta Was this translation helpful? Give feedback.
Also
Is that ok?