This package permit to check user permissions, managed by spatie/laravel-permission package, directly from JS.
-
First of all, you can install the package using composer
composer require tiaxter/laravel-permission-js
-
This step can be skipper if auto-discovery is enabled
Add package service provider into
config/app.php
file'providers' => [ ..., Tiaxter\LaravelPermissionJs\LaravelPermissionJsServiceProvider::class ];
First of all you have to include this Blade Directive inside the page where you want to use this package
@permissions
- If you're using TypeScript you will need to add this line at start of your script:
declare function can(permissionName: string): bool
Checking logged in user permission
const canUserDoSomething = can('permission name here'); // true or false
- Thanks Giorgia Marangoni logo designer for her patience