-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
extra columns in Role model creates it as an extra permission when using Spatie Laravel Translatable #325
Comments
guest i have to use:
|
please update the following parts, or republish the resource and apply your changes to avoid any future complications. //EditRole.php
$this->permissions = collect($data)
->filter(function ($permission, $key) {
return !in_array($key, ['name', 'guard_name', 'select_all', 'description']);
})
->values()
->flatten()
->unique(); // to include unique() same for $this->permissions = collect($data)
->filter(function ($permission, $key) {
return !in_array($key, ['name', 'guard_name', 'select_all', 'description']);
})
->values()
->flatten()
->unique(); // to include unique(); |
it is still a problem when i use the extra column "description" with the package: https://github.com/filamentphp/spatie-laravel-translatable-plugin When you have multiple languages the second (and maybe other extra languages) input gets added as a custom_permissions[]: As you can see there is a custom_permissions array with the title of the dutch value of "description" TextField. |
okay, i found the issue: because the Trait Translatable of the Spatie package uses the handleRecordUpdate() method. it calls "$localeData = $this->mutateFormDataBeforeSave($localeData);" again for every translatable field. this makes $this->permissions go empty in the function mutateFormDataBeforeSave() EditRole.php when called for second/third time/language. so for now i modified it like this:
then i copied the handleRecordUpdate() from the Trait, and changed this line:
to
I also had to do this for the CreateRole.php with the handleRecordCreate() function |
After adding a column "description" to the Role model with the ability of translatable via the spatie/translatable package. this column is not correctly saved. the content of the "description" will be saved as a new "Custom Permission" and added in the permissions table...
It looks to me that there should be an exclude model columns option or something.. or is there another option to this?
The text was updated successfully, but these errors were encountered: