25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Amenities <strong>and</strong> prices<br />

If you refresh the page now, it will load, but the script will have some errors. The<br />

problem is that the amenities <strong>and</strong> prices data are structured differently in the<br />

frontend app to how they are in the backend. This is because the model initially<br />

came from our database, which stores scalar values. In JavaScript, we can use<br />

richer objects which allow us to nest data, making it much easier to work with<br />

<strong>and</strong> manipulate.<br />

Here is how the model object currently looks. Notice that the amenities <strong>and</strong><br />

prices are scalar values:<br />

Figure 5.18. How the listing model currently looks This is how we need it to look, with the amenities <strong>and</strong><br />

prices as arrays:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!