Structuring a Laravel + Vue app

Posted 3 years ago by itstrueimryan

So without routing Vue seems to be more of a way to enhance an individual page rather than creating an entire single page application. Cool. But I'm still having trouble wrapping my head around how I should use Vue in my simple application.

I have two pages. One is the index, a list of "items". So when the user hits the root route he goes to the items.index view and then Vue handles retrieving all of the items by calling an api route. The items are displayed, and the user can filter these results and upvote or downvote each one. These actions are handled by Vue as well. So far so good.

The other page is an individual item page: items.view. This is where I get confused. The url is something like items/{id}-{name} and I have to check whether that item exists or not before serving up the page. So do I do that the normal way (and throw a 404 if not found) and then use Vue to grab the item again after the page loads? Or do I just load the view and then let Vue handle checking for the item and putting in some 404 text if it's not found?

Also, what if I have some model stuff that doesn't need to be altered by Vue at all? Do I load that in with Laravel and then just let Vue handle the other stuff? Where is the line between them? Should I just be going all out with Vue and only use Laravel for handling the initial routing and authentication?

I know the structure of the app is up to me but I'm really just looking for some ideas on best practices or general structure because I'm having a hard time putting it all together in my mind. Anything will help!

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

Reply to

Use Markdown with GitHub-flavored code blocks.