Skip to content

Undefined property: stdClass::$filter at /var/www/vendor/coroowicaksono/chart-js-integration/src/api/TotalRecordsController.php #173

@alishanda

Description

@alishanda

Hi
I use this library with
Laravel 10.25.2
Nova 4.27.13
Laravel and Nova with totally default settings. I just install them.

Every time I try to create any chart from model I have this error in my logs

[2023-12-14 12:17:59] local.ERROR: Undefined property: stdClass::$filter {"exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$filter at /var/www/vendor/coroowicaksono/chart-js-integration/src/api/TotalRecordsController.php:60)

It's this part of TotalRecordsController

if(isset($request->series)){
                foreach($request->series as $seriesKey => $serieslist){
                    $seriesData = (object) $serieslist;
                    $filter = (object) $seriesData->filter;

After some investigation I find out that Laravel Controller unserialize json object series as

[2023-12-14 12:19:51] local.ERROR: Array
(
    [0] => {"label":"Product A","filter":{"key":"type","value":"post_income"},"fill":false}
    [1] => {"label":"Product A","filter":{"key":"type","value":"post_income"},"fill":false}
    [2] => {"label":"Product A","filter":{"key":"type","value":"post_income"},"fill":false}
)

So final object looks like this

[2023-12-14 12:06:35] local.ERROR: stdClass Object
(
    [scalar] => {"label":"Product A","filter":{"key":"type","value":"post_income"},"fill":false}
)

When I fix this like this - everything starts to work
$seriesData = (object) json_decode($serieslist, true);

But, obviously it's not a decision. Can you please tell me what I'm doing wrong and how to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions