fxcosta / laravel-chartjs

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library
485 stars 113 forks source link

Syntax error #26

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi i am getting this error

FatalErrorException in Builder.php line 51:
syntax error, unexpected ':', expecting ';' or '{'
in Builder.php line 51

and this is my code

public function index()
    {
        $activities = $this->activities->userActivityForPeriod(
            auth()->user()->id,
            Carbon::now()->subWeeks(2),
            Carbon::now()
        )->toArray();

        $chartjs = app()->chartjs
            ->name('lineChartTest')
            ->type('line')
            ->element('lineChartTest')
            ->labels(json_encode(array_keys($activities)))
            ->datasets([
                [
                    "label"                     => "Activity (last 30 days)",
                    'backgroundColor'           => "rgba(38, 185, 154, 0.31)",
                    'borderColor'               => "rgba(38, 185, 154, 0.7)",
                    "pointBorderColor"          => "rgba(38, 185, 154, 0.7)",
                    "pointBackgroundColor"      => "rgba(38, 185, 154, 0.7)",
                    "pointHoverBackgroundColor" => "#fff",
                    "pointHoverBorderColor"     => "rgba(220,220,220,1)",
                    'data'                      => json_encode(array_values($activities)),
                ],
            ])
            ->options([]);

        return view('frontend.user.dashboard', compact('chartjs'));
    }

What im a doing wrong ?

fxcosta commented 7 years ago

@DeeJaVu what's your php version?

Currently strict mode is enabled in Builder.php and this forces you to have php7. Sorry for inconvenience.

I will remove strict mode to support previous versions, at least 5.6

ghost commented 7 years ago

yea i am using 5.6