-
Notifications
You must be signed in to change notification settings - Fork 35
Description
- Laravel Version: 9.18
- Nova Version: 4.10
- PHP Version: 8.1
- Database Driver & Version: Mysql 8
- Operating System and Version: Win10
- Browser type and version: chrome 102
Description:
Hello
When updating a model in nova 4, the HasOne
relationship is shown below the Resource. If the HasOne
resource has a field with a unique validation rule which exclude the resourceId (e.g unique:company,label,{{resourceId}}
), the resource id taken will be one of the current resource and not the HasOne
Here is an example:
I have a User
resource and a Company
resource. The User resource HasOne
company (company table has a user_id).
The company name is unique, when i update the Company
resource i have to exclude the current resourceId
.
When i am editing a User
resource i cannot save because the unique Id taken for the company will be the User one and not the company one, so the company name already exists if you are not excluding the current one..
Detailed steps to reproduce the issue on a fresh Nova installation:
Create Two resources/model/table with an HasOne
relationship.
When editing the resource you should see the HasOne
resource bellow.
Apply the Unique rule excluding the current resourceID on one field of the HasOne
model with the ->updateRules()
field method as mentionned here .
Try to update the model, you should have a validation error that the model already exists