develop
Last change
on this file since 112ba6d was 0208bbd, checked in by Berat Kjufliju <kufliju@…>, 3 years ago |
edited pagination
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Exports;
|
---|
4 |
|
---|
5 | use App\Models\Role;
|
---|
6 | use App\Models\User;
|
---|
7 | use Maatwebsite\Excel\Concerns\FromCollection;
|
---|
8 | use Maatwebsite\Excel\Concerns\WithHeadings;
|
---|
9 | use Maatwebsite\Excel\Concerns\WithMapping;
|
---|
10 |
|
---|
11 | class UsersExport implements FromCollection, WithMapping, WithHeadings
|
---|
12 | {
|
---|
13 | /**
|
---|
14 | * @return \Illuminate\Support\Collection
|
---|
15 | */
|
---|
16 | public function collection()
|
---|
17 | {
|
---|
18 | return User::all();
|
---|
19 | }
|
---|
20 |
|
---|
21 | public function map($row): array{
|
---|
22 | $fields = [
|
---|
23 | $row->id,
|
---|
24 | $row->name,
|
---|
25 | $row->surname,
|
---|
26 | $row->username,
|
---|
27 | $row->email,
|
---|
28 | $row->phone_number,
|
---|
29 | $row->is_confirmed,
|
---|
30 | $row->role_id . ' - ' . Role::find($row->role_id)->name,
|
---|
31 | $row->where('id', $row->created_by)->pluck('username')->first(),
|
---|
32 | $row->created_at,
|
---|
33 | $row->updated_at,
|
---|
34 | $row->avatar,
|
---|
35 | ];
|
---|
36 | return $fields;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public function headings(): array
|
---|
40 | {
|
---|
41 | return [
|
---|
42 | 'ID',
|
---|
43 | 'Name',
|
---|
44 | 'Surname',
|
---|
45 | 'Username',
|
---|
46 | 'Email',
|
---|
47 | 'Phone number',
|
---|
48 | 'Is confirmed',
|
---|
49 | 'Role ID - Username',
|
---|
50 | 'Created by',
|
---|
51 | 'Created at',
|
---|
52 | 'Updated at',
|
---|
53 | 'Avatar'
|
---|
54 | ];
|
---|
55 | }
|
---|
56 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.