first commit
This commit is contained in:
49
app/Exports/BookkeepingDocumentLibraryExport.php
Normal file
49
app/Exports/BookkeepingDocumentLibraryExport.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Storage;
|
||||
|
||||
class BookkeepingDocumentLibraryExport implements FromCollection, WithMapping, WithHeadings
|
||||
{
|
||||
protected $documents;
|
||||
|
||||
public function __construct($documents)
|
||||
{
|
||||
$this->documents = $documents;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
public function map($documents): array
|
||||
{
|
||||
return [
|
||||
$documents->file_name,
|
||||
(strtolower(app()->getLocale()) == 'zh_hk' ? $documents->name_chinese : $documents->name_english),
|
||||
$documents->category_name,
|
||||
$documents->user_name,
|
||||
Storage::exists($documents->file_path) ? (round(Storage::size($documents->file_path) / 1000) . 'KB') : '-',
|
||||
$documents->created_at->format('Ymd-H:i'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Document Name',
|
||||
'Company',
|
||||
'Document Category',
|
||||
'Upload User',
|
||||
'Document Size',
|
||||
'Date Uploaded',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user