diff --git a/src/Pingpong/Widget/Widget.php b/src/Pingpong/Widget/Widget.php index fda05365..96dbd30d 100644 --- a/src/Pingpong/Widget/Widget.php +++ b/src/Pingpong/Widget/Widget.php @@ -224,6 +224,21 @@ public function group($name, array $widgets) $this->registerBlade($name); } + /** + * Group some widgets, merging if previously set. + * + * @param string $name + * @param array $newWidgets + */ + public function mergeGroup($name, array $newWidgets) + { + $widgets = $this->hasGroup($name) ? $this->groups[$name] : []; + + $this->groups[$name] = array_merge($widgets, $newWidgets); + + $this->registerBlade($name); + } + /** * Determine whether a group of widgets there or not. * @@ -259,6 +274,36 @@ public function callGroup($name, $parameters = array()) return $result; } + /** + * Get a group of widgets. + * + * @param string $name + * @return array|null + */ + public function getGroup($name) + { + if (!$this->hasGroup($name)) { + return; + } + + return $this->groups[$name]; + } + + /** + * Get a collection of a group of widgets. + * + * @param string $name + * @return \Illuminate\Support\Collection|null + */ + public function collectGroup($name) + { + if (!$this->hasGroup($name)) { + return; + } + + return collect($this->groups[$name]); + } + /** * Reorder widgets. *