Vue.js with Laravel Permission

后端 未结 5 606
旧时难觅i
旧时难觅i 2020-12-31 22:38

I am in the process of integrating Laravel Permission API with Vue.JS frontend. I am using https://github.com/spatie/laravel-permission library for Laravel Permission. I am

5条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 22:44

    I would go with Ralph solution. But I find myself better using. This function to fetch the Permissions.

    public function getAllPermissionsAttribute() {
        return Auth::user()->getAllPermissions()->pluck('name');
    }
    
    

    Just a bit cleaner, and since I tend to use Roles instead of particular permissions for each User, this solution should work as well.

提交回复
热议问题