-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use exists validation without manually specifying connection name & fix multiple model support #96
Cannot use exists validation without manually specifying connection name & fix multiple model support #96
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, looks good.
As per #88 - I've found a major issue with the approach made in that PR - only one Sushi model is supported at a time. I've updated this PR to include the fix for this feature to work with multiple models. |
Thanks @danharrin |
Edit: there's already a PR for this #98This PR breaks Eloquent relationships defined in a Sushi model. When Eloquent resolves a relationship, the related model will use the connection from the parent model, unless a connection name is defined explicitly in the related model itself. See Illuminate\Database\Eloquent\Concerns::newRelatedInstance() As the parent model now returns the parent model class name as a connection name, the related model will also use this value and will not use the application's default connection.
I'll try to make a PR to resolve the issue, a bit short on time like everyone else 🙈 If anyone struggles with this, a quick fix is to define a connection name on the related model; or return the default application database connection name.
|
At the moment, the connection name needs manually specifying when using the
exists
rule.This kinda defeats the object of passing the class as the table name, as it should resolve the connection automatically 😆
Thankfully, you just need to override the
getConnectionName()
method on the model.Now, you can use: