X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/3f83c548f8bf67d3c670083f255a21897ef803d9..refs/pull/1755/head:/app/Entities/PageRevision.php diff --git a/app/Entities/PageRevision.php b/app/Entities/PageRevision.php index d30147bfc..13dc713ba 100644 --- a/app/Entities/PageRevision.php +++ b/app/Entities/PageRevision.php @@ -2,7 +2,21 @@ use BookStack\Auth\User; use BookStack\Model; +use Carbon\Carbon; +/** + * Class PageRevision + * @property int $page_id + * @property string $slug + * @property string $book_slug + * @property int $created_by + * @property Carbon $created_at + * @property string $type + * @property string $summary + * @property string $markdown + * @property string $html + * @property int $revision_number + */ class PageRevision extends Model { protected $fillable = ['name', 'html', 'text', 'markdown', 'summary']; @@ -41,13 +55,18 @@ class PageRevision extends Model /** * Get the previous revision for the same page if existing - * @return \BookStack\PageRevision|null + * @return \BookStack\Entities\PageRevision|null */ public function getPrevious() { - if ($id = static::where('page_id', '=', $this->page_id)->where('id', '<', $this->id)->max('id')) { - return static::find($id); + $id = static::newQuery()->where('page_id', '=', $this->page_id) + ->where('id', '<', $this->id) + ->max('id'); + + if ($id) { + return static::query()->find($id); } + return null; }