'required|integer', 'widget_type' => 'required|in_list[chart,text,image,filter_date,filter_dropdown]', 'grid_x' => 'permit_empty|integer|greater_than_equal_to[0]', 'grid_y' => 'permit_empty|integer|greater_than_equal_to[0]', 'grid_w' => 'permit_empty|integer|greater_than_equal_to[1]', 'grid_h' => 'permit_empty|integer|greater_than_equal_to[1]', ]; /** * @return list> */ public function forDashboard(int $dashboardId): array { return $this->select('dashboard_widgets.*') ->select('charts.name AS chart_name, charts.chart_type, charts.saved_query_id') ->join('charts', 'charts.id = dashboard_widgets.chart_id', 'left') ->where('dashboard_widgets.dashboard_id', $dashboardId) ->orderBy('dashboard_widgets.grid_y', 'ASC') ->orderBy('dashboard_widgets.grid_x', 'ASC') ->orderBy('dashboard_widgets.sort_order', 'ASC') ->orderBy('dashboard_widgets.id', 'ASC') ->findAll(); } public function deleteByDashboard(int $dashboardId): void { $this->where('dashboard_id', $dashboardId)->delete(); } }