Closed mreduar closed 1 year ago
No suggestions?
@mreduar did you found a solution?
@mreduar did you found a solution?
Unfortunately I did not find a solution, I am still open to a solution. For now I have made a reusable function that checks the user roles and I can use it as a function.
const hasRole = (user, role) => {
const roles = user.roleNames;
return roles.some((userRole) => userRole === role);
};
export { hasRole, ... };
import { hasRole } from '@/utils/generalFunctions';
const user = usePage().props.value.auth.user;;
const isAdmin = hasRole(user, 'admin');
If someone finds a solution, do not hesitate to share it.
Hi, I am trying to use the directives as functions in Vue 3, but as Vue 3 with Composition API does not have access to
this.$gates
then I can't find a way to make it work.In their documentation there are examples of this, but it doesn't work in vue 3 as usual.
I have also tried with
But it doesn't work for me.
I am using Laravel Inertia and I implement it as follows
Everything works fine in the template directives, like
v-role
but I would like to be able to use it as functions as well. Any ideas?