X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/673c74ddfc59677b55d0d7438038342f8d138569..refs/pull/205/head:/app/File.php diff --git a/app/File.php b/app/File.php index ebfa0a296..e9b77d2ea 100644 --- a/app/File.php +++ b/app/File.php @@ -5,14 +5,32 @@ class File extends Ownable { protected $fillable = ['name', 'order']; + /** + * Get the downloadable file name for this upload. + * @return mixed|string + */ + public function getFileName() + { + if (str_contains($this->name, '.')) return $this->name; + return $this->name . '.' . $this->extension; + } + /** * Get the page this file was uploaded to. - * @return mixed + * @return Page */ public function page() { return $this->belongsTo(Page::class, 'uploaded_to'); } + /** + * Get the url of this file. + * @return string + */ + public function getUrl() + { + return baseUrl('/files/' . $this->id); + } }