F
Filamentβ€’10mo ago
Wirkhof

After upgrading to 3.2 canManage stopped working

I was using this code:
public static function canAccess(): bool
{
return auth()->user()->canManageSettings();
}
public static function canAccess(): bool
{
return auth()->user()->canManageSettings();
}
and it was working. I have updated Filament 3 from v3.1.10 to v3.2.25 a few minutes ago and now I had to commented the whole function because the error is:
Call to undefined method App\Models\User::canManageSettings()
Call to undefined method App\Models\User::canManageSettings()
Any idea why was it deprecated and what should I use instead?
14 Replies
Wirkhof
WirkhofOPβ€’10mo ago
and it won't work. You will get "Call to undefined method App\Models\User::canManageSettings()" How to fix this error?
Forever
Foreverβ€’10mo ago
the canManageSettings is just a placeholder for your own code if you dont have permissions just return true
Wirkhof
WirkhofOPβ€’10mo ago
I am using Filament Shield and I did run php artisan shield:install and set user 1 as superadmin during the process
Forever
Foreverβ€’10mo ago
tthen it should be auth()->user()->hasRole("superadmin")
Wirkhof
WirkhofOPβ€’10mo ago
It worked with 3.1 hmm But it worked before the update hasRole has nothing to do with it canManageSettings worked My guess is that canManageSettings() it was removed in 3.2 or perhaps earlier But I can't find any info about the removal so far. There seem to be more update issues I see now: 'App\Models\User' does not implement method 'canAccessPanel' and Undefined type 'BezhanSalleh\FilamentShield\Traits\HasPanelShield' It seems to be related to Filament Shield probably. @Bezhan Do you know about any issues like that with Filament Shield? The version v3.1.10 worked fine with your plugin, but after updating Filament to v3.2.25 it shows these errors.
krekas
krekasβ€’10mo ago
canAccessPanel is a filament method
Forever
Foreverβ€’10mo ago
yes you need to setup your User
Forever
Foreverβ€’10mo ago
See the implenents FilamentUser on the User
ModestasV
ModestasVβ€’10mo ago
DO NOT TAG PEOPLE! #βœ…β”Šrules Now as per your issue... It would be cool if you could add at least the User model. Now we are blindly guessing what happened to your code I'd recommend you to either: 1. Revert all the changes and start again 2. Look at the git diff log and see what changed exactly If something worked on a minor version before - it should in theory work now, but it seems like you either lost something or there was an update. I would re-take the steps to configure that exact part from scratch. That way you can find the issue πŸ™‚
Wirkhof
WirkhofOPβ€’10mo ago
It seems that Bezhan did breaking changes in his plugin. My guess is you now don't need that in page at all and you just set up it in the plugin. But we will see what he will say. I know him on this forum that's why I tagged him. I am sure he is OK with that.
ModestasV
ModestasVβ€’10mo ago
Rules are rules πŸ™‚ So it doesn't matter if you are sure or not - they still apply. He was not part of this conversation, nor you went to #bezhansalleh-shield channel to post the issue. This means tagging people is not okay πŸ™‚
krekas
krekasβ€’10mo ago
If it was his package that broke something you should check github release notes to see what really changed
Want results from more Discord servers?
Add your server