From the course: Building Laravel and Vue.js 2 Web Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Building a CRUD component

Building a CRUD component

From the course: Building Laravel and Vue.js 2 Web Apps

Start my 1-month free trial

Building a CRUD component

- [Instructor] Now we'll start turning this view component into a form for managing the category records. We'll want to be able to add to, edit, or delete the categories in this prop, but it's a bad practice to mutate props, since our changes can easily be overwritten by a parent component. Here we don't have a parent component, but we will later on, and even if that parent component won't be updating the data, we'll be better off if we don't get in the habit of breaking this rule. So first, let's give this component its own data. We'll change the prop name to initial categories, both in the component and in the blade view, and in an html template, I want to use Kebab case like that. Then, we'll just initialize a data property called categories with this dot initial categories as its default value, but because a raise in objects are passed by reference in Javascript, this won't prevent us from mutating the prop at all, since categories is now just a reference to the same initial…

Contents