source: app/Exports/FoldersExport.php@ c6b84df

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

added fileTypes controller, notifications, excel export, edited views

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[c6b84df]1<?php
2
3namespace App\Exports;
4
5use App\Models\Department;
6use App\Models\Folder;
7use Maatwebsite\Excel\Concerns\FromCollection;
8use Maatwebsite\Excel\Concerns\WithHeadings;
9use Maatwebsite\Excel\Concerns\WithMapping;
10
11class FoldersExport implements FromCollection, WithMapping, WithHeadings
12{
13 /**
14 * @return \Illuminate\Support\Collection
15 */
16 public function collection()
17 {
18 return Folder::all();
19 }
20
21 public function map($row): array{
22 $fields = [
23 $row->id,
24 $row->arch_id,
25 $row->name,
26 $row->note,
27 $row->location,
28 $row->User::find($row->user_id)->username,
29 $row->Department::find($row->department_id)->name . ' - ' . Department::find($row->department_id)->code,
30 $row->is_important,
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',
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.