Exemple #1
0
 public function scopeLatestEdit($query, PageVersion $upToVersion)
 {
     $query->select("{$this->table}.*")->addSelect("{$this->table}.slotname as slotname")->join('page_versions as v1', "{$this->table}.page_vid", '=', 'v1.id')->leftJoin("{$this->table} as c2", function ($query) use($upToVersion) {
         $query->on("{$this->table}.id", '<', 'c2.id')->on("{$this->table}.slotname", '=', 'c2.slotname')->on('c2.page_vid', '<=', DB::raw("'{$upToVersion->getId()}'"));
     })->leftJoin('page_versions as v2', function ($query) use($upToVersion) {
         $query->on('c2.page_vid', '=', 'v2.id')->on('v1.page_id', '=', 'v2.page_id');
     })->whereNull('c2.id');
     return $query;
 }
Exemple #2
0
 /**
  * Mark the version as being restored from another.
  *
  * @param PageVersionInterface $version
  *
  * @return $this
  */
 public function setRestoredFrom(PageVersionInterface $version)
 {
     $this->{self::ATTR_RESTORED_FROM} = $version->getId();
     return $this;
 }
Exemple #3
0
 public function findOne($type, $slotname, PageVersion $version)
 {
     $class = 'BoomCMS\\Database\\Models\\Chunk\\' . ucfirst($type);
     return $version->getId() ? $class::getSingleChunk($version, $slotname)->first() : null;
 }
Exemple #4
0
 /**
  * Get the cache key for given chunk parameters.
  *
  * @param type        $type
  * @param type        $slotname
  * @param PageVersion $version
  *
  * @return string
  */
 public function getCacheKey($type, $slotname, PageVersion $version)
 {
     return md5("{$type}-{$slotname}-{$version->getId()}");
 }
Exemple #5
0
 public function scopeGetSingleChunk(Builder $query, PageVersion $version, $slotname)
 {
     return $query->withRelations()->where('slotname', '=', $slotname)->where('page_vid', '<=', $version->getId())->where('page_id', '=', $version->getPageId())->orderBy('page_vid', 'desc');
 }