Reputation: 703
I want to send data from page A
to page B
without use controllers, just in laravel routes. ( Laravel / VueJS3 / InertiaJS )
In my first page, I have this method:
// first.vue
tappedCourse(course: Course): void {
const data: secondParams = {
courseName: course.name,
};
Inertia.get("/second", data as any);
},
And in my route:
// web.php
Route::inertia('/second', 'Course/Second');
Finally my second page prop:
// second.vue
export default defineComponent({
props: {
courseName: {
type: String,
required: true,
default: "",
},
},
The problem is the second page prop doesn't receive the value, but if I manually insert:
// web.php
Route::inertia('/second', 'Course/Second', [
"couseName" => "Inertia + Laravel"
]);
It's working fine.
Have some way to can I get the 'query param' in my route? like $courseName
and send to my second.vue
like code above.
Note: The inertia.get
is working because I receive in URL the param name: value.
http://localhost:8000/second?name="Inertia + Laravel"
Note 2: My preference would be if it was a POST, but I didn't find in the documentation how to do it with laravel route ( Route::inertia ).
Upvotes: 2
Views: 1979
Reputation: 6105
Route::inertia
only handles GET
and HEAD
requests. Try this:
Route::post('/second', function ($courseName) {
return Inertia::render('Course/Second', compact('courseName'));
});
Upvotes: 0