Skip to content

Commit

Permalink
Add inline url
Browse files Browse the repository at this point in the history
  • Loading branch information
gabsource committed Apr 4, 2020
1 parent dba1207 commit a5099b8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,23 @@ public function getUrlAttribute()
}
}

public function getUrlInlineAttribute()
{
if ($this->isLocalStorage()) {
$extension = $this->extension;

return route('attachments.download', [
'id' => $this->uuid,
'name' => $extension ?
Str::slug(substr($this->filename, 0, -1 * strlen($this->extension) - 1)) . '.' . $this->extension :
Str::slug($this->filename),
'disposition' => 'inline',
]);
} else {
return Storage::disk($this->disk)->url($this->filepath);
}
}


public function toArray()
{
Expand Down Expand Up @@ -572,4 +589,4 @@ public function getConnectionName()
{
return config('attachments.database.connection') ?? $this->connection;
}
}
}

0 comments on commit a5099b8

Please sign in to comment.