You can do that but I would use api routes for vue instead.
If you have the same queries in both you can push the into the models.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've had a Laravel app for a while, but I recently added Vue 3 to the app for an admin dashboard. The Dash uses Vue, with values passed from blade.
All the other features on the admin side are done without Vue. So, the responses return a view, or return back to the previous page with messages.
The challenge: I have a feature I call Quick schedule links, that will book someone's appointment if it is during office hours, no one else is scheduled in that spot, and if the spot is booked by someone in that family it is only available until 2 members are in that spot.
I also have an Add->Appt section in the Menu (uses Blade), and my admin schedule allows booking open appts (uses Blade) - these both point to the same form that submits to the same function.
Is there a way to point my Vue scheduling feature to the SAME method I'm using on the other pages, but return a JSON response instead?
It seems like a huge waste to write almost the exact same function but for Vue. Or should I just duplicate it and change the responses to JSON?
My guess, now that I'm trying to clean things up, would be to pass a value that by default is null to the same function:
public function bookIfAvailable($request, $json = null) {
// do a bunch of stuff
if($json === true) {
return->response()->json([
'appts' => $appts
])
} else {
return redirect()->route('home',['appts'=>$appts,'failed'=>$failed]);
}
}
Could this work?
You can do that but I would use api routes for vue instead.
If you have the same queries in both you can push the into the models.
Please or to participate in this conversation.