Hello everyone! Iam trying to make seo system for my project, but i have troubles with that.
My ControllerBase:
    <?php
    namespace Coursor\Controllers;
    use Coursor\Models\Pages;
    use Coursor\Models\PageSeo;
    class ControllerBase extends \Phalcon\Mvc\Controller {
        protected function checkAjaxRequired() {
            if (!$this->request->isAjax()) {
                $this->response->setStatusCode(404, "Not Found");
                $this->dispatcher->forward(array(
                    'namespace' => 'Coursor\Controllers',
                    'controller' => 'errors',
                    'action' => 'error404'
                ));
                return false;
            }
            return true;
        }
        public function initialize() {
            $action = $this->router->getActionName();
            $controller = $this->router->getControllerName();
            $pages = Pages::findFirst(array(
                "page_controller = :controller: AND page_action = :action:",
                "bind" => array(
                    "controller" => $controller,
                    "action" => $action
                )
            ));
            $pageSeo = PageSeo::findFirstByPage_id($pages->id);
            if (count($pages) != 0) {
                $this->tag->setTitle($pageSeo->page_title . ' ' . count($pages));
            }
            else{
                $this->tag->setTitle('NO TITLE');
            }
        }
    }Pages model:
    <?php
    namespace Coursor\Models;
    use Phalcon\Mvc\Model;
    class Pages extends Model {
        public $id;
        public $page_controller;
        public $page_action;
        public function initialize() {
            $this->setSource("pages");
            $this->hasMany("id", "Coursor\Models\PageSeo", "page_id", array(
                'alias' => 'pageSeo'
            ));
        }
    }PageSeo model:
    <?php
    namespace Coursor\Models;
    use Phalcon\Mvc\Model;
    class PageSeo extends Model {
        public $id;
        public $page_id;
        public $page_title;
        public $meta_description;
        public $meta_keywords;
        public function initialize() {
            $this->setSource("page_seo");
            $this->belongsTo("page_id", "Coursor\Models\Pages", "id", array(
                'alias' => 'page'
            ));
        }
    }So problem is, when iam using Pages::findFirst, count($pages) always = 1, and when i change it to Pages::find, $pageSeo->page_title stop working.
- i know, that this code can be better if use relations, but i cant make them working. Pls help me to deal with this problem!