DEV Community 👩‍💻👨‍💻

Discussion on: Roles y permisos en Laravel con Inertia.js

 
eduloper profile image
Genaro Hernández Author
<script>
import { usePage } from '@inertiajs/inertia-vue3'
export default {
    created() {
        const roles = usePage().props.value.auth.roles;
        const permissions = usePage().props.value.auth.permisos;
        this.$gates.setRoles(roles);
        this.$gates.setPermissions(permissions);

        this.soyAdmin();
    },
    methods: {
        soyAdmin(){
            if(this.$gates.hasRole('admin')){
                console.log("soy admin");
            }else{
                console.log("no soy admin");
            }
        }
    }
}
</script>
Enter fullscreen mode Exit fullscreen mode