diff --git a/src/Routing/Controller.php b/src/Routing/Controller.php index 6d16cd1..6152984 100644 --- a/src/Routing/Controller.php +++ b/src/Routing/Controller.php @@ -147,6 +147,27 @@ protected function setDefault(string|array $name, mixed $value = null): void } } + /** + * Get controller data. + * + * @param string|null $name + * @param mixed $default + * + * @return mixed + * + * @throws \Exception + */ + protected function data(string|null $name = null, mixed $default = null, bool $asFluent = false): mixed + { + $data = fluent($this->controllerData); + + if ($name) { + return $data->get($name, $default); + } + + return $asFluent ? $data : $data->toArray(); + } + /** * Set controller data. *