Esempio n. 1
0
 public function getCurrentVersionQuery()
 {
     $query = DB::table('page_versions')->select([DB::raw('max(id) as id'), 'page_id'])->groupBy('page_id');
     if (Editor::isDisabled()) {
         $query->where('embargoed_until', '<=', Editor::getTime()->getTimestamp());
     }
     if (Editor::isHistory()) {
         $query->where('version.created_at', '<=', Editor::getTime()->getTimestamp());
     }
     return $query;
 }
Esempio n. 2
0
 /**
  * @param QueryBuilder $query
  *
  * @return QueryBuilder
  */
 public function scopeLatestAvailable(QueryBuilder $query)
 {
     if (Editor::isHistory()) {
         return $query->where(self::ATTR_CREATED_AT, '<=', Editor::getTime()->getTimestamp())->orderBy(self::ATTR_CREATED_AT, 'desc')->orderBy(self::ATTR_ID, 'desc');
     }
     return Editor::isDisabled() ? $this->scopeLastPublished($query) : $query->orderBy(self::ATTR_CREATED_AT, 'desc');
 }
Esempio n. 3
0
 /**
  * Attempts to get the chunk data from the cache, otherwise calls _execute to generate the cache.
  */
 public function render()
 {
     try {
         $html = $this->html();
         if ($this->editable === true || Editor::isHistory()) {
             $html = $this->addAttributesToHtml($html);
         }
         return empty($html) ? $html : $this->before . $html . $this->after;
     } catch (\Exception $e) {
         if (App::environment() === 'local') {
             throw $e;
         }
     }
 }