]> BookStack Code Mirror - bookstack/blob - app/Uploads/Attachment.php
Added locale and text direction to html templates
[bookstack] / app / Uploads / Attachment.php
1 <?php namespace BookStack\Uploads;
2
3 use BookStack\Entities\Page;
4 use BookStack\Ownable;
5
6 class Attachment extends Ownable
7 {
8     protected $fillable = ['name', 'order'];
9
10     /**
11      * Get the downloadable file name for this upload.
12      * @return mixed|string
13      */
14     public function getFileName()
15     {
16         if (str_contains($this->name, '.')) {
17             return $this->name;
18         }
19         return $this->name . '.' . $this->extension;
20     }
21
22     /**
23      * Get the page this file was uploaded to.
24      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
25      */
26     public function page()
27     {
28         return $this->belongsTo(Page::class, 'uploaded_to');
29     }
30
31     /**
32      * Get the url of this file.
33      * @return string
34      */
35     public function getUrl()
36     {
37         if ($this->external && strpos($this->path, 'http') !== 0) {
38             return $this->path;
39         }
40         return baseUrl('/attachments/' . $this->id);
41     }
42 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.