Exemplo n.º 1
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');
 }
Exemplo n.º 2
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;
 }