Skip to content

[Bug]: Hardcode App\Models\MailAttachment model is used in MailDownloadController controller #42

@abrardev99

Description

@abrardev99

What happened?

In the MailDownloadController

We are providing our own MailAttachment model using config and package should reslve the model from the config instead of harcoding.
We are customizing the storage path and using the hardcoded model is always resolve storage path from the package model (not our own model).

How to reproduce the bug

  1. Create a MailAttachment model
<?php

namespace App\Models;

class MailAttachment extends \Vormkracht10\Mails\Models\MailAttachment
{
    public function getStoragePathAttribute(): string
    {
        $tenantId = $this->mail->tenant_id ?? null;
        if ($tenantId) {
            return rtrim(config('mails.logging.attachments.root'), '/') . '/' . $tenantId . '/' . $this->getKey() . '/' . $this->filename;
        }

        return rtrim(config('mails.logging.attachments.root'), '/') . '/' . $this->getKey() . '/' . $this->filename;
    }
}
  1. Try downloading file
    It will give file not found error since files are stored with tenant path and MailDownloadController get the path without a tenant in it because because is using \Vormkracht10\Mails\Models\MailAttachment instead of config('mails.models.attachment')

Package Version

2.3

PHP Version

8.3

Laravel Version

11

Which operating systems does with happen with?

macOS

Notes

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions