Now that we have authorization for the back-end, let's add it for the front-end, too. If the user cannot delete the post, then he shouldn't even see the delete button.

For front-end permissions, we will use the package CASL Vue. First, let's install it.
npm install @casl/vue @casl/ability
To get started, we need to import abilitiesPlugin and ability from the services in the main app.js.
resources/js/app.js:
import './bootstrap'; import { createApp, onMounted } from 'vue' import router from './routes/index'import VueSweetalert2 from 'vue-sweetalert2';import useAuth from './composables/auth';import { abilitiesPlugin } from '@casl/vue'; import ability from './services/ability'; createApp({ setup() { const { getUser } = useAuth() onMounted(getUser) }}) .use(router) .use(VueSweetalert2) .use(abilitiesPlugin, ability) .mount('#app')
And what is inside this /services/ability? You define the abilities there, and one of the sections in the documentation is about ability builder. And we can copy the code in that services file.
resources/js/services/ability.js:
import { AbilityBuilder, Ability } from '@casl/ability' const { can, cannot, build } = new AbilityBuilder(Ability); export default build();
But instead of defining can and cannot here, we will define them based on...
Hi Laravel daily, We got vue, react with laravel... Great effort by you. It will be really great if you have something related to typescript now. Thank you in advance
Sorry, not in plans, as our team doesn't actively work with typescript.
Now, I am able to understand how Vue.js+Laravel of QuickAdmin panel has been build. Really helpful.
"Ant what is inside..." should probably be "And what is inside..."
it should :D
great course, now can you help me about how I can make it ready for server/deployment?
In short build assets and deploy as you would regularly
I build the assests using "npm run build", now when i deploy on server i get wrning messages in console
Loading failed for the module with source "http://[::1]:5174/resources/js/app.js" Loading failed for the module with source “http://[::1]:5174/@vite/client”
and page keeps loading, nothing shows up. I know its not in the scope of the course, but if you could have written a lesson on how to deploy, then it would have been really helpful for newbies like me.
I guess you build assets locally which are git ignored by default. We have a tutorial how to build assets and deploy them. If you really need help come to discord where it will be easier to
I honestly don't understand why we need to complicate things, make another request, and install additional packages?
Thats a great point. Even if more permissions to check were added later that solution would still work.
This was a great lesson.
can anyone help on how to prevent direct url? and also example for menu navigation tab like using canany
What do you mean?