You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The accept and destroy methods in the TeamInvitationController use route model binding to inject the requested team invitation model. However, those instances are always of class \Laravel\Jetstream\TeamInvitation. The custom model class, e.g. \App\Models\TeamInvitation is not used.
Our application creates audit logs when models are being changed using an external package. Team invitations are audited as well so \App\Models\TeamInvitation implements interface and trait provided by the external package. As the TeamInvitationController retrieves the wrong classes the "magic" will not happen when the model gets deleted.
I am more than happy to send a pull request. But before I do so what are the chances of that PR to be merged? I provided a description for two of many possible solutions below. Do you think that this is a breaking change?
The output will be \Laravel\Jetstream\TeamInvitation
Solution 1
Override resolveRouteBinding to use Jetstream::teamInvitationModel() in the base TeamInvitation model.
Downside: might not be fully backward compatible when projects created a custom team invitation model not inheriting from the base Jetstream TeamInvitation model.
Solution 2
Remove the the type-hint from the controller methods and query manually, see #651.
Downside: again not fully sure about backward compatibility when projects inherit from Jetstream base controller and override the methods mentioned before. All of sudden the base class would not have a type-hint anymore.
The text was updated successfully, but these errors were encountered:
Hmmm yeah it's probably best to use one of your two solutions. Tbh I think we can go for solution 2 since we also use the same solution like in the other PR. Feel free to attempt that PR and I'll back it up. Thanks
Description:
The accept and destroy methods in the TeamInvitationController use route model binding to inject the requested team invitation model. However, those instances are always of class
\Laravel\Jetstream\TeamInvitation
. The custom model class, e.g.\App\Models\TeamInvitation
is not used.Our application creates audit logs when models are being changed using an external package. Team invitations are audited as well so
\App\Models\TeamInvitation
implements interface and trait provided by the external package. As theTeamInvitationController
retrieves the wrong classes the "magic" will not happen when the model gets deleted.I am more than happy to send a pull request. But before I do so what are the chances of that PR to be merged? I provided a description for two of many possible solutions below. Do you think that this is a breaking change?
Steps To Reproduce:
dd(get_class($invitation));
here\Laravel\Jetstream\TeamInvitation
Solution 1
Override
resolveRouteBinding
to useJetstream::teamInvitationModel()
in the base TeamInvitation model.Downside: might not be fully backward compatible when projects created a custom team invitation model not inheriting from the base Jetstream TeamInvitation model.
Solution 2
Remove the the type-hint from the controller methods and query manually, see #651.
Downside: again not fully sure about backward compatibility when projects inherit from Jetstream base controller and override the methods mentioned before. All of sudden the base class would not have a type-hint anymore.
The text was updated successfully, but these errors were encountered: