permission:show command fails with preventAccessingMissingAttributes enabled
Cbrad24 opened this issue ยท 6 comments
Describe the bug
Laravel 9.35 introduced Eloquent Strictness parameters. Unfortunately, with strictness enabled, when running php artisan permission:show
it throws an error due to the command trying to access the team_id property on the Role model.
Versions
- spatie/laravel-permission package version: 5.10.1
- illuminate/framework package: v10.14.1
PHP version: 8.2.7
Database version: Postgres 15
To Reproduce
Steps to reproduce the behaviour:
- Spin up a Laravel app using
laravel/framework
>= 9.35. - Place
Model::preventAccessingMissingAttributes();
inAppServiceProvider::boot()
method. - Install Laravel Permission package.
- Ensure teams support is disabled.
- Run migrations.
- Run
php artisan permission:show
.
Expected behaviour
The command should run however it throws an error.
Additional context
Obviously as a workaround you can disable Eloquent Strictness to get the command to run, however this is not a great forever solution.
Environment (please complete the following information, because it helps us investigate better):
- OS: WSL Ubuntu
- Version: 20.04
@erikn69 Have you run into this?
I believe it is due to $team_key => $role->$team_key
in the end of the mapping array on line 41:
laravel-permission/src/Commands/Show.php
Lines 37 to 42 in d8f46be
($role->$team_key ?: '')
is used earlier, but doesn't scale to that array...
@erikn69 appears to be working on your branch with Model::preventAccessingMissingAttributes()
enabled, nice work ๐๐ผ
Thanks guys!
Fix released as v5.10.2