Skip to content
Advertisement

Multiple Layouts in Laravel Blade, Vue-Router [closed]

I am trying to separate user & admin functionality but can’t find a satisfactory solution.

After login, the user is authenticated and then he is redirected to either user or admin blade view depending upon the role.

“Now, in the user.blade file, I just want to load user-related routes & components and vice versa. This way, I won’t need any ACL in Vue-router and extra fuss, I guess”.

But how do I make this work? I have searched everywhere but can’t find a proper solution…

Advertisement

Answer

You could create 3 different JS files, like vendor.js for e.g. Vue and other libraries, app.js for the user area and admin.js for the admin area.

Then in user.blade.php you include vendor.js and app.js and in admin.blade.php you include vendor.js and admin.js.

app.js will include all routes for the normal user, while admin.js will include all routes/components etc for the admin area.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement