Example #1
0
 /**
  * ### Bileşeni çalıştırma
  * run() metodu, bir controller gibi işlev görür.
  *
  * @return $this
  */
 public function run()
 {
     $contents = Content::ContentTypeId($this->config['content_type_id'])->LanguageId(null, $this->config['language_id'])->Published()->orderBy($this->config['order_by'], $this->config['order'])->take($this->config['limit'])->SiteId()->get();
     return view("ContentWidget::content_widget", ['config' => $this->config])->with('contents', $contents);
 }
Example #2
0
 /**
  * ### Benzer / Seçilmiş İçerikler
  * İçerikle ilişkilendirilmiş benzer içerikleri getirir.
  *
  * @param $content : içerik (collection)
  *
  * @example Content::related($content);
  *
  * @return mixed (collection)
  */
 public function related($content)
 {
     $selected_contentIds = $content->getMeta('selected-contents');
     if ($selected_contentIds) {
         $imploded_ids = implode(',', $selected_contentIds);
         $selected_contents = \Agola\Core\Content\Models\Content::LanguageId(false, $content->language->id)->whereIn('id', $selected_contentIds)->orderByRaw(DB::raw("FIELD(id, {$imploded_ids})"))->Published()->SiteId()->get();
         if ($selected_contents) {
             return $selected_contents;
         }
     }
 }