source: app/Exports/FilesExport.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.1 KB
RevLine 
[c6b84df]1<?php
2
3namespace App\Exports;
4
5use App\Models\File;
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 FilesExport implements FromCollection, WithMapping, WithHeadings
13{
14 /**
15 * @return \Illuminate\Support\Collection
16 */
17 public function collection()
18 {
19 return File::all();
20 }
21
22 public function map($row): array{
23 $fields = [
24 $row->id,
25 $row->name,
26 $row->location,
27 $row->getSize($row->location) . ' MB',
28 $row->Folder::find($row->folder_id)->name . ' - ' . Folder::find($row->folder_id)->arch_id,
29 $row->created_at,
30 $row->updated_at
31 ];
32 return $fields;
33 }
34
35 public function headings(): array
36 {
37 return [
38 'ID',
39 'Name',
40 'Location',
41 'Size',
42 'Folder - Archive ID',
43 'Created at',
44 'Updated at'
45 ];
46 }
47}
Note: See TracBrowser for help on using the repository browser.