develop
Last change
on this file since 195c3cf was 4b7e2d3, checked in by beratkjufliju <kufliju@…>, 3 years ago |
bug fixes, edited export, added fileSeeder for DB testing
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Exports;
|
---|
4 |
|
---|
5 | use App\Models\Department;
|
---|
6 | use App\Models\Folder;
|
---|
7 | use App\Models\User;
|
---|
8 | use Maatwebsite\Excel\Concerns\FromCollection;
|
---|
9 | use Maatwebsite\Excel\Concerns\WithHeadings;
|
---|
10 | use Maatwebsite\Excel\Concerns\WithMapping;
|
---|
11 |
|
---|
12 | class FoldersExport implements FromCollection, WithMapping, WithHeadings
|
---|
13 | {
|
---|
14 | /**
|
---|
15 | * @return \Illuminate\Support\Collection
|
---|
16 | */
|
---|
17 | public function collection()
|
---|
18 | {
|
---|
19 | return Folder::all();
|
---|
20 | }
|
---|
21 |
|
---|
22 | public function map($row): array{
|
---|
23 | $fields = [
|
---|
24 | $row->id,
|
---|
25 | $row->arch_id,
|
---|
26 | $row->name,
|
---|
27 | $row->note,
|
---|
28 | $row->location,
|
---|
29 | $row->user_id . ' - ' . User::find($row->user_id)->username,
|
---|
30 | $row->Department::find($row->department_id)->name . ' - ' . Department::find($row->department_id)->code,
|
---|
31 | $row->is_important,
|
---|
32 | $row->created_at,
|
---|
33 | $row->updated_at
|
---|
34 | ];
|
---|
35 | return $fields;
|
---|
36 | }
|
---|
37 |
|
---|
38 | public function headings(): array
|
---|
39 | {
|
---|
40 | return [
|
---|
41 | 'ID',
|
---|
42 | 'Archive ID',
|
---|
43 | 'Name',
|
---|
44 | 'Note',
|
---|
45 | 'Location',
|
---|
46 | 'Created by ID - Username',
|
---|
47 | 'Department name - code',
|
---|
48 | 'Is important',
|
---|
49 | 'Created at',
|
---|
50 | 'Updated at'
|
---|
51 | ];
|
---|
52 | }
|
---|
53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.