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

ExportAsCsv export all records instead of the relationship ones only #5925

Closed
tommiekn opened this issue Oct 3, 2023 · 6 comments
Closed
Labels
needs more info More information is required stale

Comments

@tommiekn
Copy link

tommiekn commented Oct 3, 2023

  • Laravel Version: 9.52.15
  • Nova Version: 4.27.13
  • PHP Version: 8.2

Description:

While running the action ExportAsCsv to export records from a Relationship resource, and using the "Select all" feature in the table, the CSV generated contains the whole database instead of only the related records.

Detailed steps to reproduce the issue on a fresh Nova installation:

Resource Customer have a relationship with many Releases.
In the Customer page, if I try to export all Releases with ExportAsCsv i get the whole table of Releases instead of only the ones related to the Customer.
If i manually select some record form the table it works fine and it exports only that records, the issue is only while using the "Select all" feature in the table.

Model Customer:

class Customer extends Model
{
//
  public function releases()
  {
        return $this->hasMany(Release::class, 'ownerId');
  }
//
}

Nova Resource Customer:

class Customer extends Resource
{
  public function fields(Request $request)
   {
    //
    HasMany::make('Releases'),
    //
  }

  public function actions(Request $request)
      {
          return [
              ExportAsCsv::make('Export')->nameable()->withTypeSelector(true),
          ];
      }
}

Nova Resource Releases:

class Release extends Resource
{

  public function fields(Request $request)
  {
          return [
            BelongsTo::make('Customer'),
            ];
  }

  public function actions(Request $request)
      {
          return [
              ExportAsCsv::make('Export')->nameable()->withTypeSelector(true),
          ];
      }

}
@Milkhan
Copy link

Milkhan commented Oct 9, 2023

Same here, an action should only run for the related rows but instead its running all the rows from the db when you select 'Select All' in the hasmany view. I think its a very dangerous bug if we are not doing something wrong.

@crynobone
Copy link
Member

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

@crynobone crynobone added the needs more info More information is required label Oct 10, 2023
@tommiekn
Copy link
Author

tommiekn commented Oct 16, 2023

@crynobone i cant dev a full repository just to reproduce the issue and i cant share the current repository we are working i am afraid. as the issue is shared by another user too i assume theres something somewhere that is creating this bug?
let me know if you need any further info from our install and will provide

@crynobone
Copy link
Member

I can't reproduce the issue. If you can recreate the issue on a fresh project then we have a starting point to debug the problem.

@tommiekn
Copy link
Author

I am sorry but i dont have the time to recreate the issue on a fresh project; if you have any questions regarding my project im open to help but i don't have the time to debug this, as this issue is shared with another user, is for sure something that happens so someone should figure out a way to reproduce and fix it.
Maybe @Milkhan may have time to recreate it?

@crynobone
Copy link
Member

Hey there,

We're closing this issue because it's inactive, already solved, old, or not relevant anymore. Feel free to open up a new issue if you're still experiencing this problem.

@crynobone crynobone closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info More information is required stale
Projects
None yet
Development

No branches or pull requests

3 participants