50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Exports;
|
||
|
|
|
||
|
|
use App\Models\Admin\User;
|
||
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||
|
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
||
|
|
// use Maatwebsite\Excel\Concerns\WithMapping;
|
||
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||
|
|
|
||
|
|
// abstract class ParentClass {
|
||
|
|
// abstract public function collection();
|
||
|
|
// abstract public function headings() : array;
|
||
|
|
// abstract public function map($user) : array;
|
||
|
|
// }
|
||
|
|
|
||
|
|
class UsersExport implements FromCollection , WithHeadings
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return \Illuminate\Support\Collection
|
||
|
|
*/
|
||
|
|
|
||
|
|
public function collection()
|
||
|
|
{
|
||
|
|
$userData = User::select('id','full_name','created_at','mob_number','email')
|
||
|
|
->get();
|
||
|
|
|
||
|
|
return $userData;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function headings(): array {
|
||
|
|
return [
|
||
|
|
'id','full_name','created_at','mob_number','email'
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
// public function map($user): array {
|
||
|
|
// return [
|
||
|
|
// $user->id,
|
||
|
|
// $user->full_name,
|
||
|
|
// $user->email,
|
||
|
|
// $user->created_at,
|
||
|
|
// $user->updated_at
|
||
|
|
// ];
|
||
|
|
// }
|
||
|
|
|
||
|
|
|
||
|
|
}
|