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
tasksfrom the Vuex state withv-for - Renders each task’s
title,description, and assigneduser - Provides a Complete button that dispatches
completeTask(task.id) - Provides a Delete button that dispatches
deleteTask(task.id) - Renders a form bound with
v-modelto a localnewTaskobject (title,description,user) - On form submit, calls the local
addTask()method which validates fields before dispatching to the store
- Maps
tasksfrom Vuex state viamapState - Maps
fetchTasks,addTask,completeTask,deleteTask,showAssignedTasks, andshowAllTasksfrom Vuex actions viamapActions - Calls
fetchTasks()in themountedlifecycle hook to load tasks on page load - Local
addTask()method validates that all three fields are non-empty before dispatching to the store
Vuex store
The store is defined inresources/js/store.js and registered globally in app.js.
- State
- Mutations
- Actions
- Getters
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.
axios.defaults.baseURLis set tohttp://127.0.0.1:8000— this must be updated to match the deployed server URL in production.- The
X-Requested-With: XMLHttpRequestheader 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.
Build pipeline (Laravel Mix)
Assets are compiled by Laravel Mix 6 (a Webpack wrapper). The entire build configuration lives inwebpack.mix.js:
- Takes
resources/js/app.jsas the Webpack entry point - Enables the Vue single-file component (
.vue) loader - Outputs the compiled bundle to
public/js/app.js