Laravel 5.7, Vue.js and zizaco/entrust

Posted 2 months ago by valeraefimov696

Hello. I try to use entrust in my project. But I don’t know how to properly use entrust and Vue.js so that it would be as safe as in Views.

@role ('admin')
    <p> This is visible. </ p>
@endrole

I tried to transfer all the permissions to my component.

 $ permissions = User :: getAllPermissions ();

and

<v-btn dark color = "indigo" @ click = "openDialogCreate" v-if = "$ root.hasPermissions (['add_post'])" ">
                                To add
                                <v-icon dark> add </ v-icon>
                            </ v-btn>
methods: {
        hasPermissions (data) {
            var vm = this;
            var check = false;
            if (Object.keys (this.getMe) .length> 0) {
                data.map (function (value, key) {
                    if (vm.getMe.permissions.includes (value)) {
                        check = true;
                    }
                });
                return check;
            }

        },
}

but it seems to me a bad decision.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.