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

[QUESTION] HOW TO GET ALL CHECKED DATA IN BULK ACTIOIN #385

Closed
zulfikar-ditya opened this issue Apr 2, 2023 · 2 comments
Closed

[QUESTION] HOW TO GET ALL CHECKED DATA IN BULK ACTIOIN #385

zulfikar-ditya opened this issue Apr 2, 2023 · 2 comments

Comments

@zulfikar-ditya
Copy link
Contributor

  • Laravel Version: 10.5.1
  • PHP Version: 8.1.2
  • Splade JS Version (npm): 1.4.7
  • Splade PHP Version (composer): 1.4.7

let say we have case like generating item receiving report from many purchasing data, and we need all the checked data in data table, is that any option for this features?

@pascalbaljet
Copy link
Contributor

This was undocumented, but the before and after callbacks receive all ids. When all rows are selected, the callbacks receive an array with a single * item:

$table->bulkAction(
    label: 'Notify users',
    before: function (array $selectedIds) {
        $users = User::query()
            ->unless($selectedIds === ['*'], fn ($query) => $query->whereIn('id', $selectedIds))
            ->get();
 
        Mail::to($users)->send(new ImportantNotification);
    }
);

@zulfikar-ditya
Copy link
Contributor Author

maybe can help with it pr for doc get all selected data

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

No branches or pull requests

2 participants