Permission
Overview #
In admin panel, all components are equipped with TEnabledPermit so you can control their permission with enabled()
and enabledWhen()
method.
Resource #
You can set permission to Resource
class App extends Application
{
protected function sidebar()
{
return [
"Customers"=>Customer::create()->enabled(function(){
//Only shown when user is admin
return $this->app()->user()->hasRole("admin");
})
];
}
}
Learn more about Resource.
Glass #
You can set permission to Glass
class Customer extends Resource
{
protected function glasses()
{
return [
MostValueCustomer::create()->enabled(function(){
//Only allow this glass if user is manager
return $this->app()->user()->hasRole("manager");
}),
...
];
}
}
Learn more about Glass.
Filter #
You can set permission to Filter
class Customer extends Resource
{
protected function filters()
{
return [
CountryFilter::create()->enabled(function(){
//Only allow this filter if user is manager
return $this->app()->user()->hasRole("manager");
}),
...
];
}
}
Learn more about Filter.
Action #
You can set permission to Action
class Customer extends Resource
{
protected function actions()
{
return [
DeleteAction::create()->enabled(function(){
//Only allow delete if user is admin
return $this->app()->user()->hasRole("admin");
}),
...
];
}
}
Learn more about Action.
Screens and other components #
You can set permissions to 4 screens of Resource and even the components inside each screen.
class Customer extends Resource
{
protected function onCreated()
{
//Create screen permission
$this->createScreen()->enabled(function(){
//Only allow manager to access create screen
return $this->app()->user()->hasRole("manager");
});
//Search Box permission
$this->listScreen()->searchBox()->enabled(function(){
//Only show search box if user is manager
return $this->app()->user()->hasRole("manager");
});
}
}
Learn more about Screens and components
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.