models/Post.php
public function setUrl($pageName, $controller)
    {
        $params = [
            'id'   => $this->id,
            'slug' => $this->slug
        ];

        $params['category'] = $this->categories->count() ? $this->categories->first()->slug : null;

        // Expose published year, month and day as URL parameters.
        if ($this->published) {
            $params['year']  = $this->published_at->format('Y');
            $params['month'] = $this->published_at->format('m');
            $params['day']   = $this->published_at->format('d');
        }

        return $this->url = $controller->pageUrl($pageName, $params);
    }
public function setUrl($pageName, $controller)
    {
        $params = [
            'id'   => $this->id,
            'slug' => $this->slug
        ];

        $params['category'] = $this->categories->count() ? $this->categories->first()->slug : null;

        // Expose published year, month and day as URL parameters.
        if ($this->published) {
            $params['year']  = $this->published_at->format('Y');
            $params['month'] = $this->published_at->format('m');
            $params['day']   = $this->published_at->format('d');
        }

        return $this->url = $controller->pageUrl($pageName, $params);
    }
public function setUrl ( $ pageName , $ controller ) { $ params = [ 'id' => $ this -> id , 'slug' => $ this -> slug ] ; $ params [ 'category' ] = $ this -> categories -> count ( ) ? $ this -> categories -> first ( ) -> slug : null ; // Expose published year, month and day as URL parameters. if ( $ this -> published ) { $ params [ 'year' ] = $ this -> published_at -> format ( 'Y' ) ; $ params [ 'month' ] = $ this -> published_at -> format ( 'm' ) ; $ params [ 'day' ] = $ this -> published_at -> format ( 'd' ) ; } return $ this -> url = $ controller -> pageUrl ( $ pageName , $ params ) ; }
Sets the "url" attribute with a URL to this object.
@param string $pageName
@param Cms\Classes\Controller $controller
Sets the url attribute with a URL to this object .