src/Model/Table/WidgetsTable.php
public function saveDashboardWidgets(string $dashboardId, array $widgets = []): bool
    {
        $result = false;

        if (empty($widgets)) {
            return $result;
        }

        foreach ($widgets as $item) {
            $widget = [
                'dashboard_id' => $dashboardId,
                'widget_id' => $item['id'],
                'widget_type' => $item['type'],
                'widget_options' => json_encode($item),
                'row' => 0,
                'column' => 0,
            ];

            $entity = $this->newEntity();
            $entity = $this->patchEntity($entity, $widget);

            if ($this->save($entity)) {
                $result = true;
            }
        }

        return $result;
    }
public function saveDashboardWidgets(string $dashboardId, array $widgets = []): bool
    {
        $result = false;

        if (empty($widgets)) {
            return $result;
        }

        foreach ($widgets as $item) {
            $widget = [
                'dashboard_id' => $dashboardId,
                'widget_id' => $item['id'],
                'widget_type' => $item['type'],
                'widget_options' => json_encode($item),
                'row' => 0,
                'column' => 0,
            ];

            $entity = $this->newEntity();
            $entity = $this->patchEntity($entity, $widget);

            if ($this->save($entity)) {
                $result = true;
            }
        }

        return $result;
    }
public function saveDashboardWidgets ( string $ dashboardId , array $ widgets = [ ] ) : bool { $ result = false ; if ( empty ( $ widgets ) ) { return $ result ; } foreach ( $ widgets as $ item ) { $ widget = [ 'dashboard_id' => $ dashboardId , 'widget_id' => $ item [ 'id' ] , 'widget_type' => $ item [ 'type' ] , 'widget_options' => json_encode ( $ item ) , 'row' => 0 , 'column' => 0 , ] ; $ entity = $ this -> newEntity ( ) ; $ entity = $ this -> patchEntity ( $ entity , $ widget ) ; if ( $ this -> save ( $ entity ) ) { $ result = true ; } } return $ result ; }
Save Dashboard Widgets

@param string $dashboardId of the instance
@param mixed[] $widgets of the dashboard

@return bool $result of the save operation.
Save Dashboard Widgets