Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bearriverweb's avatar

Date will not display and does not show any errors in console

I am trying to get a date to display on the vue, but whatever I try it doesn't work for either the current date, or what I need which is the date 6 months prior to current date. I hope that I am posting this correctly, I am pretty new this site and Laravel in general. Here is my code:

class DashboardController extends Controller { //

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);
}

Dashboard.vue: <template #header> Dashboard

    <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>
</app-layout>

This is the last part of the code that pertains on OutstandingFirm.vue {{ customer.FirmName }} date 6 months ago:{{ sixmoago }}

0 likes
2 replies
LaryAI's avatar
Level 58

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.

  1. Ensure Data is Passed Correctly from Controller to View:

    In your DashboardController, you are already passing the sixmoago variable 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);
    }
    
  2. Ensure Data is Received in Vue Component:

    In your Dashboard.vue, you need to make sure that the sixmoago data is being received and used correctly. You should define props to receive the data from the controller.

  3. Ensure Data Binding in Child Components:

    If you need to use sixmoago in a child component like OutstandingFirm.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.

Bearriverweb's avatar

Yes, this is how I have it setup. I did add the prop to OutstandingFirm.vue just now based on this recommendation, however it still does not work. It does not display the date.

Please or to participate in this conversation.