Skip to content
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

FilamentShield::getDefaultPermissionIdentifier(): Return value must be of type string, Illuminate\Support\Stringable returned #468

Open
Bratej opened this issue Dec 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Bratej
Copy link

Bratej commented Dec 16, 2024

Describe the bug
When trying to create a new role in Filament the error is shown:
BezhanSalleh\FilamentShield\FilamentShield::getDefaultPermissionIdentifier(): Return value must be of type string, Illuminate\Support\Stringable returned
BezhanSalleh\FilamentShield\FilamentShield::getLocalizedResourcePermissionLabel(): Return value must be of type string, Illuminate\Support\Stringable returned

Note

🚨 Before creating a new issue, please make sure to:
1️⃣ Search closed issues to check if your question or issue has already been addressed.
2️⃣ Read the documentation to see if your question is answered there.
3️⃣ **If steps and requirements outlined aren't fulfilled the issue will be deleted.
The docs often cover common questions and problems.

If your issue is new and not covered elsewhere, please provide all relevant details below:

Expected behavior
Page that allows creating a new role.

please complete the following information:

  • OS: Linux/Docker
  • Filament 3.2.130
  • Version 3.3.4

Additional context
The problem seems to be in the getLocalizedResourcePermissionLabel and getDefaultPermissionIdentifier functions that expect string as a return type but Illuminate\Support\Stringable is returned. If I cast the return as a string e.g.:
return (string) Str::of($resource)
->afterLast('Resources\')
->before('Resource')
->replace('\', '')
->snake()
->replace('_', '::');

and
return (string) (Lang::has("filament-shield::filament-shield.resource_permission_prefixes_labels.{$permission}", app()->getLocale())
? __("filament-shield::filament-shield.resource_permission_prefixes_labels.{$permission}")
: Str::of($permission)->headline());

(or use: Str::of($permission)->headline()->toString() )

It works. Using Laravel 11.35.1

@Bratej Bratej added the bug Something isn't working label Dec 16, 2024
@Bratej
Copy link
Author

Bratej commented Dec 18, 2024

Same error is triggered with artisan shield:generate in the CanGeneratePolicy command. The return should be string but it's Illuminate\Support\Stringable. Casting to string makes it work.

@bezhanSalleh
Copy link
Owner

bezhanSalleh commented Dec 19, 2024

are you by any chance using the configurePermissionIdentifierUsing() or altering anything else? because i have 16 apps in prod and i haven't been able to reproduce what you are describing. submit a repro repo and i will take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants