tiaxter/laravel-permission-js

Check spatie/laravel-permission directly in JavaScript

v0.0.2 2020-11-08 17:02 UTC

This package is auto-updated.

Last update: 2025-06-26 19:14:34 UTC


README

💡 Purpose

This package permit to check user permissions, managed by spatie/laravel-permission package, directly from JS.

🚀 Installation

  • 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
    ];

🔰 Getting started

First of all you have to include this Blade Directive inside the page where you want to use this package

@permissions

💻 Basic usage

  • 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

🎨 Credits