Files
cheerstothe_season_2.0/app/Exports/CustomerExportSelected.php
sayliraut 78a9221216 change
2024-05-28 19:29:09 +05:30

57 lines
1.1 KiB
PHP

<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use App\Models\IamPrincipal;
use Illuminate\Support\Collection;
class CustomerExportSelected 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;
}
/**
* @return array
*/
public function headings(): array
{
return [
'first_name',
'email_address',
'date_of_birth',
'phone_number'
];
}
}