I have an overview section, when my details button is clicked for an item in the overview I want to display my database items from that item on another page.
How can I get the id from my route to make a get request to that id in vue?
overview component
<a class="button float-right" @click="getAccount(account.id)"/>
// in my methods
getAccount(id) {
window.location.href = '/accounts/' + id;
}
My laravel route
Route::get('/accounts/{account}', 'PageController@details')->name('details.index');
I know I can use route model binding for this but would like to keep it in a vue component
Controller
public function details()
{
return view('layouts.details');
}
Details component
export default {
data() {
return{
account : {
title: null,
information: null,
cb: null,
qp: null,
price: null,
skills: [],
}
}
},
created() {
this.fetchAccount();
},
methods: {
fetchAccount() {
// make axios request to the id to get account information
}
}
}
I'm also not sure what the best approach for this would be. Should I even work with laravel web routes for this page? (If I don't, I still need to inherit the layouts.app file, not sure how that would be done without using the routes)
Any tips?