darryldecode / laravel-starter-kit

Laravel 7.0~ Starter Kit Powered by VueJS + Material Design(Vuetify)
https://laravel-starter-kit.darrylfernandez.com/
302 stars 131 forks source link

Retrieving data with a condition #41

Closed vikela closed 4 years ago

vikela commented 4 years ago

I am liking this kit and everything works well but have hit a snag. I have managed to add a Post model then Users will have many Posts. I can retrieve the Posts but I want to click on a User and get a page with all the related users's Posts.

Using axios to get related User Posts lists with the following in Users.list vue

This is the link I use to open the Posts page.

`<v-btn @click="$router.push({name:'posts.list',params:{id:item.id}})" class="ma-0" outlined fab small color="success" title="View Posts">

mdi-tray-full` ` axios.get('/admin/posts/' + self.propUserId,{params: params}).then(function(response) { self.items = response.data.data.data; self.totalItems = response.data.total; self.pagination.totalItems = response.data.total; (cb || Function)(); });` I am trying to pass the User Id to the router js through `self.propUserId` `path: '/:id', name: 'posts.list', component: require('./posts/components/PostLists'), props: (route) => ({propUserId: route.params.id}),` I have the following router in the web router within the `Route::prefix('admin')->namespace('Admin')->middleware(['auth'])->group(function() { Route::resource('posts/{id}','PostController'); .....` I am not getting any Posts