53 lines
1.0 KiB
PHP
53 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use App\Models\IamPrincipal;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
|
|
|
|
class customer_export_selected implements FromCollection ,WithHeadings
|
|
{
|
|
protected $ids;
|
|
|
|
public function __construct($ids)
|
|
{
|
|
$this->ids = $ids;
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Support\Collection
|
|
*/
|
|
public function collection()
|
|
{
|
|
|
|
$selectedCareIds = explode(',', $this->ids);
|
|
|
|
$selected_customer = IamPrincipal::whereIn('id', $selectedCareIds)
|
|
->orderBy('id', 'Desc')
|
|
->select(
|
|
'first_name',
|
|
'email_address',
|
|
'date_of_birth',
|
|
'phone_number'
|
|
)
|
|
->get();
|
|
return $selected_customer;
|
|
}
|
|
|
|
//function header in excel
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'first_name',
|
|
'email_address',
|
|
'date_of_birth',
|
|
'phone_number'
|
|
];
|
|
}
|
|
|
|
|
|
}
|