orderBy('name', 'asc'); if ($this->search) { $term = '%' . mb_strtolower($this->search) . '%'; $query->where(function ($q) use ($term) { $q->whereRaw('UNACCENT(LOWER(name)) LIKE UNACCENT(?)', [$term]) ->orWhereRaw('UNACCENT(LOWER(email)) LIKE UNACCENT(?)', [$term]) ->orWhereRaw('UNACCENT(LOWER(COALESCE(phone, \'\'))) LIKE UNACCENT(?)', [$term]); }); } return $query->get()->map(fn($u) => [ $u->name, $u->phone ?? '', $u->email ?? '', ]); } public function headings(): array { return ['Nome', 'Telefone', 'E-mail']; } public function title(): string { return 'Contatos'; } public function columnWidths(): array { return ['A' => 40, 'B' => 22, 'C' => 35]; } public function styles(Worksheet $sheet): array { return [ 1 => [ 'font' => ['bold' => true, 'color' => ['argb' => 'FFFFFFFF']], 'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['argb' => 'FF661D75']], 'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER], ], ]; } }