Passing a class from Livewire Component class to view

Is it possible to pass a ColumnChartModel to the view in a livewire component? in my code below, $columnChartModel is defined in the livewire class but null in the view.

    public function render()
    {
        $columnChartModel =
            (new ColumnChartModel())
                ->setTitle('Expenses by Type')
                ->addColumn('Food', 100, '#f6ad55')
                ->addColumn('Shopping', 200, '#fc8181')
                ->addColumn('Travel', 300, '#90cdf4');

        return view('livewire.report-daily-calls-by-hour', compact('columnChartModel'));
    }

I cannot pass it as a property, such as:

public $columnChartModel;

because livewire does not support this as a property.

  • What is your error?

    – 

Leave a Comment