How to call a function as callback in addField? #418
-
I'm using spatie for manage the permissions, they are stored in the following way: So I'm using this addField properties to display it:
what I'm trying to do is load a translation of each permission from my custom language file, but I cannot find any method that allow me to do this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The first idea that comes to my mind is to use an accessor together with the
and then in your model add the accessor like this:
Laravel 8:
Most probably you will have to customise the translation function |
Beta Was this translation helpful? Give feedback.
The first idea that comes to my mind is to use an accessor together with the
attribute
property.You can do something like this instead of the current
name
and then in your model add the accessor like this:
Laravel 9:
Laravel 8:
Most probably you will have to customise the translation function
__($value)
to your needs.If you think that in all places where you read the
name
you would like it translated, then you could just make the accessor for…