Skip to content
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

Add a database connection to exists: validation #183

Open
stefvanesch opened this issue Nov 16, 2023 · 4 comments
Open

Add a database connection to exists: validation #183

stefvanesch opened this issue Nov 16, 2023 · 4 comments
Labels
need-info More information about this issue is required

Comments

@stefvanesch
Copy link

We are using this package for a websites that is multi tenant using the spatie package. We now have an issue where the validation if a menu exists will fail because it will check the landlord database.

return array_merge([
    'menu_id' => "required|exists:$menusTableName,id",
    // ...
])

The menu's in this case are stored in the tenant database so we need to overrule the database connection in the validation. We will create a pull request to address this issue.

@KasparRosin
Copy link
Member

This seems like a valid issue, but rather rare one and easily fixable by extending our MenuBuilder tool class. Personally feel like this doesn't deserve us bloating our configuration file.

Since it's a tool class and not used internally, I recommend you extend it in your own project and call your class with updated methods inside the tools function in NovaServiceProvider class.

@KasparRosin
Copy link
Member

KasparRosin commented Jan 4, 2024

Since it's a tool class and not used internally

I was wrong about this, we use it internally to, which complicates the solution a bit, but with relative ease you can still override the vendor class in your project.

@KasparRosin
Copy link
Member

https://github.com/outl1ne/nova-menu-builder/blob/main/config/nova-menu.php#L18
@stefvanesch if you assign your table name to connection.table_name, it should already try to look up the correct database connection and table. Could you try it, I think that solves your problem the easiest.

@KasparRosin KasparRosin added the need-info More information about this issue is required label Jan 4, 2024
@stefvanesch
Copy link
Author

@KasparRosin sadly that didn't work for us. I'm not sure why not anymore. We've forked your package and added the changes there to make it work for our situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info More information about this issue is required
Projects
None yet
Development

No branches or pull requests

2 participants