1 <?php namespace BookStack;
4 class PageRevision extends Model
6 protected $fillable = ['name', 'html', 'text', 'markdown', 'summary'];
9 * Get the user that created the page revision
10 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
12 public function createdBy()
14 return $this->belongsTo(User::class, 'created_by');
18 * Get the page this revision originates from.
19 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
21 public function page()
23 return $this->belongsTo(Page::class);
27 * Get the url for this revision.
30 public function getUrl()
32 return $this->page->getUrl() . '/revisions/' . $this->id;
36 * Get previous revision
37 * @return \BookStack\PageRevision
39 public function getPrevious()
41 if ($id = PageRevision::where('id', '<', $this->id)->max('id')) {
42 return PageRevision::find($id);
48 * @return \BookStack\PageRevision
50 public function getNext()
52 if ($id = PageRevision::where('id', '>', $this->id)->min('id')) {
53 return PageRevision::find($id);