Files

34 lines
815 B
PHP
Raw Permalink Normal View History

2026-02-08 15:16:35 +07:00
<?php
namespace App\Exports;
use App\Models\ActivityLog;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class ActivityLogExport implements FromCollection, WithHeadings, WithMapping
{
public function collection()
{
return ActivityLog::with('user')->latest()->get();
}
// Header Excel
public function headings(): array
{
return ['Waktu', 'Pelaksana', 'Aksi', 'Deskripsi', 'IP Address'];
}
// Mapping Data per Baris
public function map($log): array
{
return [
$log->created_at->format('d/m/Y H:i:s'),
$log->user->name ?? 'System',
$log->action,
$log->description,
$log->ip_address,
];
}
}