v-show="$can('user_create') && $can('role_create')"
Can`t add multiple permission on vue component
I have a system builded with laravel7.X and vue js2. Also i have declared some permission for each users. So i have builded a button as reusable component and i call this button on top of each table, basically is a button with create method, (it mean `create user, or create role, ...) but now i want to add permission for each button if user can create new users or new roles.
this is vue js button
<v-button v-show="$can('user_create'), $can('role_create')" type="success" v-if="addRecordModal" @click.prevent="showModal" class="add-record">
Add Record
</v-button>
i fetch this button on other component, for example on users table and roles table
<btn-custom-action role="add-user-module"
@showModal="showModal"
:addRecordModal="addRecordModal"
></btn-custom-action>
Like this v-show="$can('user_create'), $can('role_create')" it is not working as well as i need couse if a user have at last one role of these it will show button for both components but i want to show button only in component where user can have permission to add records.
@tilamap365 Ok now I understand, it's a reusable button.
Inside the button component, you need to have a show property and use it to show / hide the button.
// Inside your customButtonComponent
<button v-show = "show">My super button</button>
And you assign true or false to this property from the parent component.
<custom-button-component :show="$can('do_anything')"></custom-button-component>
...
<custom-button-component :show="$can('do_something_else')"></custom-button-component>
Please or to participate in this conversation.