|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/coaching/coaching.bizkrypt.com/app/Exports/ |
Upload File : |
<?php
namespace App\Exports;
use App\Models\User;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithDrawings;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
class NewStudentExport implements FromCollection, WithHeadings, WithMapping, WithDrawings
{
public function headings(): array
{
return [
'id',
'user_unique_id',
'ip_address',
'admin_id',
'name',
'email',
'phone',
'fcm_token',
'password',
'remember_token',
'status',
'profile_pics',
'user_type',
'created_at',
'updated_at',
];
}
public function map($item): array
{
return [
$item->id,
$item->user_unique_id,
$item->ip_address,
$item->admin_id,
$item->name,
$item->email,
$item->phone,
$item->fcm_token,
$item->password,
$item->remember_token,
$item->status,
$item->profile_pics,
$item->user_type,
$item->phone_number,
$item->created_at,
$item->updated_at,
];
}
public function collection()
{
return User::get();
}
public function drawings()
{
// dd(public_path('/admin/images/profile/1677841375.png'));
$drawing = new Drawing();
$drawing->setName('signature');
$drawing->setDescription('This is my signatuer');
$drawing->setPath(public_path('/admin/images/profile/1677841375.png'));
// $drawing->setHeight(90);
$drawing->setWidthAndHeight(10,10);
$drawing->setCoordinates('R1');
return $drawing;
}
// public function styles(Worksheet $sheet)
// {
// $count = count(User::get());
// $sheet->getStyle('A1:G1')->getFont()->setBold(true);
// $sheet->getStyle('A1:G1')->applyFromArray([
// 'borders' => [
// 'allBorders' => [
// 'borderStyle' => Border::BORDER_THIN,
// 'color' => ['argb' => '000'],
// ],
// ],
// ]);
// $sheet->getStyle('A1:G1')->getFill()->applyFromArray([
// 'fillType' => 'solid',
// 'rotation' => 0,
// 'color' => ['rgb' => '8D4019'],
// ]);
// }
}