<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeffersonsimaogoncalves / nova-permission example snippets
// in app/Providers/NovaServiceProvider.php
// ...
public function tools()
{
return [
// ...
\JeffersonSimaoGoncalves\NovaPermission\NovaPermissionTool::make(),
];
}
// in config/nova.php
'middleware' => [
// ...
\JeffersonSimaoGoncalves\NovaPermission\ForgetCachedPermissions::class,
],
// ...
use Laravel\Nova\Fields\MorphToMany;
public function fields(Request $request)
{
return [
// ...
MorphToMany::make('Roles', 'roles', \JeffersonSimaoGoncalves\NovaPermission\Nova\Role::class),
MorphToMany::make('Permissions', 'permissions', \JeffersonSimaoGoncalves\NovaPermission\Nova\Permission::class),
];
}
// ...
use JeffersonSimaoGoncalves\NovaPermission\Nova\Fields\PermissionBooleanGroup;
use JeffersonSimaoGoncalves\NovaPermission\Nova\Fields\RoleBooleanGroup;
public function fields(Request $request)
{
return [
// ...
RoleBooleanGroup::make('Roles'),
PermissionBooleanGroup::make('Permissions'),
];
}
// ...
use JeffersonSimaoGoncalves\NovaPermission\Nova\Fields\RoleSelect;
public function fields(Request $request)
{
return [
// ...
RoleSelect::make('Role', 'roles'),
];
}
// in app/Providers/NovaServiceProvider.php
// ...
public function tools()
{
return [
// ...
\JeffersonSimaoGoncalves\NovaPermission\NovaPermissionTool::make()
->roleResource(CustomRole::class)
->permissionResource(CustomPermission::class),
];
}
// ...
use JeffersonSimaoGoncalves\NovaPermission\Nova\Fields\PermissionBooleanGroup;
use JeffersonSimaoGoncalves\NovaPermission\Nova\Fields\RoleSelect;
public function fields(Request $request)
{
return [
// ...
RoleBooleanGroup::make('Roles', 'roles', null, 'description'),
PermissionBooleanGroup::make('Permissions', 'permissions', null, 'description'),
RoleSelect::make('Role', 'roles', null, 'description'),
];
}
// in app/Providers/NovaServiceProvider.php
// ...
public function tools()
{
return [
// ...
\JeffersonSimaoGoncalves\NovaPermission\NovaPermissionTool::make()
->rolePolicy(RolePolicy::class)
->permissionPolicy(PermissionPolicy::class),
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.