source: app/Exports/UsersExport.php@ f40603e

develop
Last change on this file since f40603e was 0208bbd, checked in by Berat Kjufliju <kufliju@…>, 3 years ago

edited pagination

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[c6b84df]1<?php
2
3namespace App\Exports;
4
5use App\Models\Role;
6use App\Models\User;
7use Maatwebsite\Excel\Concerns\FromCollection;
8use Maatwebsite\Excel\Concerns\WithHeadings;
9use Maatwebsite\Excel\Concerns\WithMapping;
10
11class 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,
[4b7e2d3]30 $row->role_id . ' - ' . Role::find($row->role_id)->name,
[c6b84df]31 $row->where('id', $row->created_by)->pluck('username')->first(),
32 $row->created_at,
[0208bbd]33 $row->updated_at,
34 $row->avatar,
[c6b84df]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',
[4b7e2d3]49 'Role ID - Username',
[c6b84df]50 'Created by',
51 'Created at',
[0208bbd]52 'Updated at',
53 'Avatar'
[c6b84df]54 ];
55 }
56}
Note: See TracBrowser for help on using the repository browser.