]> BookStack Code Mirror - bookstack/blobdiff - app/File.php
Added initial translation into German (formal)
[bookstack] / app / File.php
index ebfa0a29618a0e7c2a4bda01fc0f98a34206fb9d..e9b77d2ea192b4ddaafd7e3814b98d7ac6fa1b3c 100644 (file)
@@ -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);
+    }
 
 }