-
Hi all, I'm looking for an optimised solution to balance the usage of ide-helper, phpstan and laravel-translatable packages. Let's dive in: Translations are stored in json in the database which results in an array being returned for the translated property instead of a plain string. When using the package barryvdh/laravel-ide-helper and generating model docs the translated columns are correctly marked as array. For example:
However PHPStan identifies the usage of the translated string as incorrect because the "array" is accessed as string You can however mark the property on your model as Any ideas for a better solution? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I have similar issue with phpstan ... |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, I fixed the issue using a custom Model Hook. You'll need to publish the ide-helper config file using: php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config Then you'll need to create a model hook class and add its reference to the See this gist for the code: https://gist.github.com/SolveSoul/f9db8b9370d96c1aa4273b2280cb9b89 |
Beta Was this translation helpful? Give feedback.
-
thanks @SolveSoul |
Beta Was this translation helpful? Give feedback.
For what it's worth, I fixed the issue using a custom Model Hook.
You'll need to publish the ide-helper config file using:
php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config
Then you'll need to create a model hook class and add its reference to the
ide-helper.php
config file under themodel_hooks
section.See this gist for the code:
https://gist.github.com/SolveSoul/f9db8b9370d96c1aa4273b2280cb9b89