adhik13th
5 months ago
394
2
Vue

How create middleware on laravel SPA from cretueusebiu

Posted 5 months ago by adhik13th

iam new and just learning about laravel SPA . i try to create project laravel spa from github : https://github.com/cretueusebiu/laravel-vue-spa .

so next step i want to add middleware , but in the structure i dont know what happens to do .

this folder on

js
  middleware
        admin.js
        auth.js
        check-auth.js
        guest.js
        locale.js

        

on admin.js

import store from '~/store'

export default (to, from, next) => {
  if (store.getters['auth/user'].role !== 'admin') {
    next({ name: 'home' })
  } else {
    next()
  }
}

this role is admin but on table users i didnt see anything about role or anything , please tell me . someone who already uses this , i just wanna ask , how to can create some middleware like , users ,admin ,super admin , or anything . thankyou

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