I'm actually struggling with passing data to a GET request page, I'm trying to pass data from the database to the Dashboard.vue component (using Laravel 8 Inertia.js stack)
But nothing happened, why?
Controller component:
public function index(Request $request) { return Inertia::render('Dashboard', [ 'percentages' => $percentages = DB::table('profits')->where('user_id', $request->user()->id)->sum('percentage'), 'profits' => $profits = DB::table('profits')->where('user_id', $request->user()->id)->sum('total_profit'), ]); }
front end:
<div class="container"> <div class="row"> <div class="col-sm-5 text-center fund-profits"> {{profits}} </div> <div class="col-sm-2 text-center nomad-separator"> | </div> <div class="col-sm-5 text-center fund-profits"> {{percentages}} </div> </div> </div> <script> import JetApplicationLogo from './../Jetstream/ApplicationLogo' export default { props: ['percentages', 'profits'], components: { JetApplicationLogo, }, } </script>
I encountered a similar problem yesterday. I used inertia when rendering again in
routes/web.php
and I think an override occurred. Try not using inertia in your routes, worked for me.