source: app/Exports/FoldersExport.php@ 4521f25

Last change on this file since 4521f25 was e78295c, checked in by beratkjufliju <kufliju@…>, 3 years ago

added version

  • Property mode set to 100644
File size: 1.2 KB
Line 
1<?php
2
3namespace App\Exports;
4
5use App\Models\Department;
6use App\Models\Folder;
7use App\Models\User;
8use Maatwebsite\Excel\Concerns\FromCollection;
9use Maatwebsite\Excel\Concerns\WithHeadings;
10use Maatwebsite\Excel\Concerns\WithMapping;
11
12class 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->created_at,
32 $row->updated_at
33 ];
34 return $fields;
35 }
36
37 public function headings(): array
38 {
39 return [
40 'ID',
41 'Archive ID',
42 'Name',
43 'Note',
44 'Location',
45 'Created by ID - Username',
46 'Department name - code',
47 'Is important',
48 'Created at',
49 'Updated at'
50 ];
51 }
52}
Note: See TracBrowser for help on using the repository browser.