coroo / nova-chartjs

A Simple Dashboard Chart in Laravel Nova using Chart JS. Starting create your own dashboard with Chart JS Integration can save your time and help you maintain consistency across standard elements such as Bar, Stacked, Line, Area, Doughnut and Pie Chart.
https://coroo.github.io/nova-chartjs
MIT License
215 stars 72 forks source link

Laravel 10 Compatibility? #151

Closed ndberg closed 1 year ago

ndberg commented 1 year ago

Is this package already Laravel 10 compatible? I just tried it on a completely new project and it does not look like, as I got this error:

Object of class Illuminate\\Database\\Query\\Expression could not be converted to string at /var/www/l10/vendor/coroowicaksono/chart-js-integration/src/api/TotalRecordsController.php:174

To Reproduce Steps to reproduce the behavior:

  1. Create new Laravel 10 Project
  2. Install Nova 4 and coroo/nova-chartjs
  3. migrate and add some users
  4. Add the Code for a Simple Stacked Chart with Laravel Model to the Main Dashboard:
    class Main extends Dashboard
    {
    /**
     * Get the cards for the dashboard.
     *
     * @return array
     */
    public function cards()
    {
        return [
              (new StackedChart())
                ->title('Revenue')
                ->model('\App\Models\User') // Use Your Model Here
                ->width('2/3'),
        ];
    }
    }
chiragsenjaliya commented 1 year ago

@ndberg just add ->col_xaxis('created_at') after ->model('\App\Models\User') .

The issue is when we don't provide col_xaxis it takes reference from DB::raw($tableName . '.created_at') which creates an issue here.