]> BookStack Code Mirror - bookstack/blobdiff - app/PageRevision.php
Merge branch 'diff' of git://github.com/younes0/BookStack into younes0-diff
[bookstack] / app / PageRevision.php
index 1ffd63dbd584700376c983e39a4f4c1c8ce36800..e5721f5aa1dc08f790eb011daa4ee2fbb706aba2 100644 (file)
@@ -32,4 +32,25 @@ class PageRevision extends Model
         return $this->page->getUrl() . '/revisions/' . $this->id;
     }
 
+    /**
+     * Get previous revision
+     * @return \BookStack\PageRevision
+     */
+    public function getPrevious()
+    {
+        if ($id = PageRevision::where('id', '<', $this->id)->max('id')) {
+            return PageRevision::find($id);
+        }
+    }
+
+    /**
+     * Get next revision
+     * @return \BookStack\PageRevision
+     */
+    public function getNext()
+    {
+        if ($id = PageRevision::where('id', '>', $this->id)->min('id')) {
+            return PageRevision::find($id);
+        }
+    }
 }