feat: Implement Secure R2 Storage with Private Bucket and Proxy Controller

This commit is contained in:
dyzulk
2026-01-04 18:07:22 +07:00
parent b4ea949bf2
commit 4dc4b3d498
5 changed files with 102 additions and 7 deletions

View File

@@ -22,4 +22,18 @@ class TicketAttachment extends Model
{
return $this->belongsTo(TicketReply::class, 'ticket_reply_id');
}
protected $appends = ['download_url'];
public function getDownloadUrlAttribute()
{
// Legacy: if it's already a full URL, return it
if (filter_var($this->file_path, FILTER_VALIDATE_URL)) {
return $this->file_path;
}
// Secure: return the API endpoint
// Assuming route prefix is /api (standard Laravel)
return url("/api/support/attachments/{$this->id}");
}
}