F
Filamentβ€’11mo ago
Harvey

canAccess() method not working when added to Custom Page

What I am trying to do: I was trying to use the canAccess() method to authorise certain User's access to a custom Filament page. I want it to remove the navigation menu item. What I did: Create a page using filament:create-page, add the canAccess method and make it always return false to test it. My issue: The menu item has not been removed. I cannot see any reference to this function in the inherited classes, so a bit lost on how Filament actually uses it. Code:
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;

class TestPage extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.test-page';

public static function canAccess(): bool
{
return false;
}
}
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;

class TestPage extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.test-page';

public static function canAccess(): bool
{
return false;
}
}
Docs link: https://filamentphp.com/docs/3.x/panels/pages#authorization
No description
2 Replies
Solution
Harvey
Harveyβ€’11mo ago
Harvey
HarveyOPβ€’11mo ago
nevermind, it was in added in v3.2 I was on v3.1πŸ’€
Want results from more Discord servers?
Add your server