Hi,
in your example you use Permit
class in App.php
But if I use pages the function sidebar()
is located in the page file and I get an error Call to undefined method koolreport\dashboard\Permit::hasSpecialReportAccess()
I tried to move permision()
function to my MemberPage.php but it has not helped.
MemberPage.php
use Utils\AppPermit;
class MemberPage extends Main
{
protected function onCreated()
{
$this->loginRequired(true); // Do need login to access
}
protected function permision()
{
return AppPermit::create();
}
protected function sidebar()
{
return [
'Special Reports' => Section::create()->enabledWhen('hasSpecialReportAccess')->sub([
'Wine Report' => WineReportBoard::create()->enabledWhen('hasSpecialReportAccess')->icon('fas fa-glass')
]),
];
...
AppPermit.php
class AppPermit extends \koolreport\dashboard\Permit
{
protected function beAdmin($request, $sender)
{
return $request->user()->hasRole('admin');
}
protected function hasSpecialReportAccess($request, $sender)
{
return $request->user()->hasRole('special-report');
}
}
So, how to use Permit
class with Pages? Or what am I doing wrong?