Files
cheerstothe_season_2.0/app/Exports/customer_export_selected.php
sayaliparab ca2a1036fc Export
2024-06-13 13:34:34 +05:30

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'
];
}
}