Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Stepayo's avatar

Laravel Vue SPA - Frontend logic for models

Hi, I am creating a Laravel 10 & Vue 3 SPA and I'm not exactly sure where should I put my logic that retrieves/creates/updates Laravel models on the Vue side. Mostly I've seen two approaches, composables or Pinia stores. For example, if I have Post model I don't know where to store functions and variables such as post, getPost, posts, getPosts, updatePost, createPost etc. From what I see, composables are cleaner and should be used for reusable logic which makes sense in this scenario. On the other hand, stores additionally have shared state, so if I get posts on first page, they'll already be loaded if user goes to the second page that also uses posts. Which is the better practice to use and what are your thoughts about it?

0 likes
1 reply
martinbean's avatar

@stepayo You should have code (a service or something) that retrieves and persists data. You should use a store for exactly that: storing things. It’s not where you would put logic to make network requests to fetch or send data to an API.

Please or to participate in this conversation.