Exemple #1
0
 /**
  * get content of this category/section
  * {category is a child section of a section}
  *
  * @param        $limit
  * @param array  $relations
  * @param bool   $is_published
  * @param bool   $filter_featured
  * @param bool   $is_featured
  * @param string $order_by
  * @param string $sorting
  *
  * @return mixed
  */
 private function getData($limit, $relations = [], $is_published = false, $filter_featured = false, $is_featured = false, $order_by = 'publish_date', $sorting = 'DESC')
 {
     if ($is_published) {
         $query = $this->content->published();
     } else {
         $query = $this->content;
     }
     if (is_array($relations) && !empty($relations)) {
         foreach ($relations as $relation) {
             $query = $query->with($relation);
         }
     }
     if ($filter_featured) {
         $query = $query->where('featured', $is_featured);
     }
     $query = $query->orderBy($order_by, $sorting);
     return $query->paginate($limit);
 }
Exemple #2
0
     * @return mixed
     */
    public function admin()
    {
        return $this->belongsTo('Agency\\Cms\\Admin', 'ADMIN');
    }
    /**
     * @return mixed
     */
    public function section()
    {
        return $this->belongsTo("Agency\\Cms\\Section", "NEWS");
    }
    /**
     * @return mixed
     */
    public function writer()
    {
        return $this->belongsTo('Agency\\Writer', 'WRITER');
    }
    /**
     * @return mixed
     */
    public function comments()
    {
        return $this->hasMany('Agency\\Comment', 'ON');
    }
}
Content::observe(new CachingObserver());
Content::observe(new PublishedContentObserver());
Exemple #3
0
 /**
  * Get a new Content instance from an instance of \Agency\Content.
  *
  * @param  \Agency\Content $content
  *
  * @return \Agency\RealTime\Content
  */
 public static function makeFromContent(PublishedContent $content)
 {
     return new static(Dictionary::make(['content' => ['id' => $content->getKey(), 'type' => self::TYPE_ANY]]));
 }