PHP code example of digitalcloud / nova-permission-tool
1. Go to this page and download the library: Download digitalcloud/nova-permission-tool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitalcloud / nova-permission-tool example snippets
use DigitalCloud\PermissionTool\PermissionTool;
// ....
public function tools()
{
return [
// ...
new PermissionTool(),
// ...
];
}
namespace App\Nova\Actions;
use Laravel\Nova\Actions\Action;
class YourAction extends Action {
// ...
public $name = 'send email';
// ...
}
namespace App\Nova;
use App\Nova\Actions\YourAction;
use Illuminate\Support\Facades\Gate;
use Illuminate\Http\Request;
class Quotation extends Resource {
// ...
public function actions(Request $request) {
return [
(new YourAction())->canSee(function ($request) {
return Gate::check('send email'); // the same name of the action
})->canRun(function ($request) {
return Gate::check('send email'); // the same name of the action
})
];
}
// ...
}