Initial commit: Struktur aplikasi ilycats
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user