1 <?php namespace BookStack\Uploads;
3 use BookStack\Entities\Page;
6 class Attachment extends Ownable
8 protected $fillable = ['name', 'order'];
11 * Get the downloadable file name for this upload.
12 * @return mixed|string
14 public function getFileName()
16 if (str_contains($this->name, '.')) {
19 return $this->name . '.' . $this->extension;
23 * Get the page this file was uploaded to.
24 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
26 public function page()
28 return $this->belongsTo(Page::class, 'uploaded_to');
32 * Get the url of this file.
35 public function getUrl()
37 if ($this->external && strpos($this->path, 'http') !== 0) {
40 return baseUrl('/attachments/' . $this->id);