File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
8
8
9
9
- Added functionality to display BooleanColumn as Yes/No instead of icons.
10
10
- Added ButtonGroupColumn for multiple LinkColumns in one group. Pretty much built in action buttons support.
11
+ - Added bulk action export example to docs.
11
12
12
13
## [ 2.5.0] - 2022-05-03
13
14
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : Bulk Action Export
3
+ weight : 3
4
+ ---
5
+
6
+ Here's an example on exporting your data from a bulk action using [ Laravel Excel] ( https://laravel-excel.com ) :
7
+
8
+ ``` php
9
+ use App\Exports\UsersExport;
10
+ use Maatwebsite\Excel\Facades\Excel;
11
+
12
+ public function bulkActions(): array
13
+ {
14
+ return [
15
+ 'export' => 'Export',
16
+ ];
17
+ }
18
+
19
+ public function export()
20
+ {
21
+ $users = $this->getSelected();
22
+
23
+ $this->clearSelected();
24
+
25
+ return Excel::download(new UsersExport($users), 'users.xlsx');
26
+ }
27
+ ```
28
+
29
+ The ` UsersExport ` class is a simple example of how to export data from a bulk action:
30
+
31
+ ``` php
32
+ <?php
33
+
34
+ namespace App\Exports;
35
+
36
+ use App\Models\User;
37
+ use Maatwebsite\Excel\Concerns\FromCollection;
38
+
39
+ class UsersExport implements FromCollection
40
+ {
41
+ public $users;
42
+
43
+ public function __construct($users) {
44
+ $this->users = $users;
45
+ }
46
+
47
+ public function collection()
48
+ {
49
+ return User::whereIn('id', $this->users)->get();
50
+ }
51
+ }
52
+ ```
You can’t perform that action at this time.
0 commit comments