source: app/Exports/FilesExport.php@ e2e83fc

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