Saved page
We will now add the saved page to Vuebnb. Let's begin by creating the component file:
$ touch resources/assets/components/SavedPage.vue
Next, we'll create a new route with this component at the path /saved
.
resources/assets/js/router.js
:
... import SavedPage from '../components/SavedPage.vue'; let router = new VueRouter({ ... routes: [ ... { path: '/saved', component: SavedPage, name: 'saved' } ] });
Let's also add some server-side routes to the Laravel project. As discussed above, the saved page uses exactly the same data as the home page. This means that we can just call the same controller methods used for the home page.
routes/web.php
:
Route::get('/saved', 'ListingController@get_home_web');
routes/api.php
:
Route::get('/saved', 'ListingController@get_home_api');
Now we will define the SavedPage
component. Beginning with the script
tag, we will import the ListingSummary
component we created back in Chapter 6, Composing Widgets with Vue.js Components. We'll also create...