Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify the file name with a method when using the Exportable concern #4116

Open
wants to merge 1 commit into
base: 3.1
Choose a base branch
from

Conversation

lorenzolosa
Copy link

@lorenzolosa lorenzolosa commented Apr 9, 2024

This PR provides a way to define the file name to be used by the Exportable concern with a method (instead of an attribute).

1️⃣ Why should it be added? What are the benefits of this change?

Currently, it is possible to set a file name to be used by the Exportable trait, by setting a $fileName attribute.

In my experience, however, the name of the file usually depends on some attribute of the export class: e.g., I might want to export all the articles in a year, and call the file "articles2024.csv". I cannot currently do that unless I specify the file name in each method call (e.g., (new ArticlesExport)->download('articles2024.xlsx')), which is not ideal since it results in duplication if it needs to be done in different places.

2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.

No.

3️⃣ Does it include tests, if possible?

Yes.

4️⃣ Any drawbacks? Possible breaking changes?

No breaking changes: if the getFileName() method is not present, it will fall back to the $fileName attribute.

5️⃣ Mark the following tasks as done:

  • Checked the codebase to ensure that your feature doesn't already exist.
  • Take note of the contributing guidelines.
  • Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • Added tests to ensure against regression.

6️⃣ Thanks for contributing! 🙌

My pleasure!
If you believe that it would be more in line to this package's style to have a WithFileName interface to identify when the getFileName() method should be use, I can rewrite it in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant