getData(); } public function messages() { return $this->getData('messages'); } private function getData($type = 'rules') { $action=$this->route()->getAction(); list($controller, $method)=explode('@', $action['controller']); if (!method_exists($this, $method)) { return []; } return $this->$method()[$type]?:[]; } }