/** * Metodo llamado por la función INDEX. * @return array */ protected function dataIndex() { $posts = Posts::selectAll(); $output = []; if ($posts !== \FALSE) { $output = $posts->getAll(); } return ['posts' => $output]; }
/** * Metodo llamado por la función INDEX. * @return array */ protected function dataIndex() { $posts = Posts::selectAll(); $output = []; if ($posts !== \FALSE) { $output = $posts->getAll(); } foreach ($output as $post) { $title = $post->getPostTitle(); if (isset($title[30])) { $title = substr($title, 0, 30) . ' [...]'; } $post->setPostTitle($title); } return ['posts' => $output]; }