예제 #1
0
 /**
  * Saves a page revision into the system.
  * @param Page $page
  * @return $this
  */
 public function saveRevision(Page $page)
 {
     $revision = $this->pageRevision->fill($page->toArray());
     $revision->page_id = $page->id;
     $revision->created_by = auth()->user()->id;
     $revision->created_at = $page->updated_at;
     $revision->save();
     // Clear old revisions
     if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) {
         $this->pageRevision->where('page_id', '=', $page->id)->orderBy('created_at', 'desc')->skip(50)->take(5)->delete();
     }
     return $revision;
 }
예제 #2
0
 /**
  * Saves a page revision into the system.
  * @param Page $page
  * @param null|string $summary
  * @return $this
  */
 public function saveRevision(Page $page, $summary = null)
 {
     $revision = $this->pageRevision->fill($page->toArray());
     if (setting('app-editor') !== 'markdown') {
         $revision->markdown = '';
     }
     $revision->page_id = $page->id;
     $revision->slug = $page->slug;
     $revision->book_slug = $page->book->slug;
     $revision->created_by = auth()->user()->id;
     $revision->created_at = $page->updated_at;
     $revision->type = 'version';
     $revision->summary = $summary;
     $revision->save();
     // Clear old revisions
     if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) {
         $this->pageRevision->where('page_id', '=', $page->id)->orderBy('created_at', 'desc')->skip(50)->take(5)->delete();
     }
     return $revision;
 }