It looks like you're trying to pass the date from your Laravel controller to your Vue component, but it isn't displaying as expected. Let's break down the solution step by step.
-
Ensure Data is Passed Correctly from Controller to View:
In your
DashboardController, you are already passing thesixmoagovariable to the view. This part looks correct:public function show() { /** @var User $user */ $user = Auth::user(); $customer = $user->customer; $sixmoago = Carbon::now()->subMonths(6)->format('m/d/Y'); $outFirm = $customer->outstandingFirm()->get(); $outInvoices = $customer->outstandingInvoices()->orderByDesc('WorkOrderNo', 'asc')->limit(5)->get(); $client = "test"; $data = [ 'client' => $client, 'outInvoices' => $outInvoices, 'outFirm' => $outFirm, 'sixmoago' => $sixmoago, ]; return Inertia::render('Dashboard/Dashboard', $data); } -
Ensure Data is Received in Vue Component:
In your
Dashboard.vue, you need to make sure that thesixmoagodata is being received and used correctly. You should definepropsto receive the data from the controller.<template> <app-layout> <template #header> Dashboard </template> <div class="py-2"> <div class="max-w-7xl mx-auto sm:px-6 lg:px-4"> <div class="my-5"></div> <outstanding-firm :customers="outFirm" /> </div> </div> <div class="py-2"> <div class="max-w-7xl mx-auto sm:px-6 lg:px-4"> <div class="my-5"></div> <paid-invoices :invoices="outInvoices" /> </div> </div> <div> Date 6 months ago: {{ sixmoago }} </div> </app-layout> </template> <script> export default { props: { outFirm: Array, outInvoices: Array, sixmoago: String } } </script> -
Ensure Data Binding in Child Components:
If you need to use
sixmoagoin a child component likeOutstandingFirm.vue, you should pass it as a prop to that component as well.<!-- In Dashboard.vue --> <outstanding-firm :customers="outFirm" :sixmoago="sixmoago" /> <!-- In OutstandingFirm.vue --> <template> <div> <div v-for="customer in customers" :key="customer.id"> {{ customer.FirmName }} </div> <div> Date 6 months ago: {{ sixmoago }} </div> </div> </template> <script> export default { props: { customers: Array, sixmoago: String } } </script>
By following these steps, you should be able to display the date 6 months ago in your Vue component. Make sure to check the browser console for any errors and ensure that the data is being passed correctly at each step.