]> BookStack Code Mirror - bookstack/blob - app/Image.php
Started work on revisions in image manager
[bookstack] / app / Image.php
1 <?php namespace BookStack;
2
3 use Images;
4
5 class Image extends Ownable
6 {
7
8     protected $fillable = ['name'];
9
10     /**
11      * Get a thumbnail for this image.
12      * @param  int $width
13      * @param  int $height
14      * @param bool|false $keepRatio
15      * @return string
16      * @throws \Exception
17      */
18     public function getThumb($width, $height, $keepRatio = false)
19     {
20         return Images::getThumbnail($this, $width, $height, $keepRatio);
21     }
22
23     /**
24      * Get the revisions for this image.
25      * @return \Illuminate\Database\Eloquent\Relations\HasMany
26      */
27     public function revisions()
28     {
29         return $this->hasMany(ImageRevision::class);
30     }
31
32     /**
33      * Get the count of revisions made to this image.
34      * Based off numbers on revisions rather than raw count of attached revisions
35      * as they may be cleared up or revisions deleted at some point.
36      * @return int
37      */
38     public function revisionCount()
39     {
40         return intval($this->revisions()->max('revision'));
41     }
42 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.