Files
Document-Management-System-…/app/Exports/UsersExport.php

82 lines
2.0 KiB
PHP
Raw Normal View History

2021-04-07 06:32:42 -04:00
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithPreCalculateFormulas;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\BeforeWriting;
use Maatwebsite\Excel\Events\BeforeSheet;
use Maatwebsite\Excel\Events\AfterSheet;
class UsersExport
implements
FromCollection,
WithHeadings,
WithMapping,
ShouldAutoSize,
WithTitle,
WithCustomStartCell
{
protected $users;
public function __construct($users){
$this->users = $users;
}
public function collection()
{
return $this->users;
}
public function headings(): array
{
return [
2021-04-09 10:42:08 -04:00
'Код',
'Имя',
'Электронный адрес',
'Номер телефон',
'Дата рождения',
'Должность',
'Подразделение',
'Активирован',
2021-04-07 06:32:42 -04:00
];
}
public function map($user): array
{
return [
$user->id,
$user->name,
$user->email,
$user->tel,
explode(' ', $user->birthday)[0],
$user->title_id,
$user->department_id,
$user->active,
];
}
public function title(): string
{
2021-04-09 10:42:08 -04:00
return 'Список пользавателя';
2021-04-07 06:32:42 -04:00
}
public function startCell(): string
{
return 'A1';
}
}