Skip to main content
The frontend is a Vue.js 2 single-page component embedded in a Blade view. All state is managed centrally by Vuex, and all HTTP calls to the Laravel backend are made through Axios actions in the store.

Component structure

There is one primary component in this application:

TaskList.vue

TaskList.vue is the only user-facing Vue component. It renders an unordered list of pending tasks and a form to add new ones. Template responsibilities:
  • Iterates over tasks from the Vuex state with v-for
  • Renders each task’s title, description, and assigned user
  • Provides a Complete button that dispatches completeTask(task.id)
  • Provides a Delete button that dispatches deleteTask(task.id)
  • Renders a form bound with v-model to a local newTask object (title, description, user)
  • On form submit, calls the local addTask() method which validates fields before dispatching to the store
Script responsibilities:
  • Maps tasks from Vuex state via mapState
  • Maps fetchTasks, addTask, completeTask, deleteTask, showAssignedTasks, and showAllTasks from Vuex actions via mapActions
  • Calls fetchTasks() in the mounted lifecycle hook to load tasks on page load
  • Local addTask() method validates that all three fields are non-empty before dispatching to the store
The component defines mounted twice — once as a shorthand method property and once as a full lifecycle hook. Only the second definition (the mounted() hook) is executed by Vue. The first is overridden.

Vuex store

The store is defined in resources/js/store.js and registered globally in app.js.
The store holds a single top-level state property: an array of task objects fetched from the backend.
Each task object in the array mirrors the database row shape returned by the TaskController:

app.js bootstrapping

app.js is the Webpack entry point. It imports Vue, Vuex, the Vuex store instance, the TaskList component, and Axios, then mounts the Vue application on the #app DOM element.
Key bootstrap decisions:
  • axios.defaults.baseURL is set to http://127.0.0.1:8000 — this must be updated to match the deployed server URL in production.
  • The X-Requested-With: XMLHttpRequest header tells Laravel to treat requests as AJAX, which affects how it formats validation error responses.
  • The store is passed directly to the root Vue instance, making it available in all child components via this.$store.
The hardcoded baseURL in app.js will fail in any environment other than a local dev server running on port 8000. Use an environment variable (e.g. process.env.MIX_APP_URL) for deployments.

Build pipeline (Laravel Mix)

Assets are compiled by Laravel Mix 6 (a Webpack wrapper). The entire build configuration lives in webpack.mix.js:
This single chain:
  1. Takes resources/js/app.js as the Webpack entry point
  2. Enables the Vue single-file component (.vue) loader
  3. Outputs the compiled bundle to public/js/app.js