feat: Add Excel export functionality for reports (projects, phases, inspections) using maatwebsite/excel

This commit is contained in:
2026-05-25 17:21:25 +02:00
parent fd166edbc6
commit c556a4910b
8 changed files with 745 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Exports;
use App\Models\Inspection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
class InspectionsExport implements FromCollection, WithHeadings
{
public function collection()
{
return Inspection::select([
'id',
'project_id',
'feature_id',
'template_id',
'status',
'notes',
'created_at',
'updated_at'
])->get();
}
public function headings(): array
{
return [
'ID',
'ID Proyecto',
'ID Característica',
'ID Plantilla',
'Estado',
'Notas',
'Creado el',
'Actualizado el'
];
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Exports;
use App\Models\Phase;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
class PhasesExport implements FromCollection, WithHeadings
{
public function collection()
{
return Phase::select([
'id',
'project_id',
'name',
'progress_percent',
'start_date',
'end_date',
'created_at',
'updated_at'
])->get();
}
public function headings(): array
{
return [
'ID',
'ID Proyecto',
'Nombre',
'Progreso (%)',
'Fecha de inicio',
'Fecha de fin',
'Creado el',
'Actualizado el'
];
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Exports;
use App\Models\Project;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
class ProjectsExport implements FromCollection, WithHeadings
{
public function collection()
{
return Project::select([
'id',
'name',
'description',
'start_date',
'end_date',
'status',
'created_at',
'updated_at'
])->get();
}
public function headings(): array
{
return [
'ID',
'Nombre',
'Descripción',
'Fecha de inicio',
'Fecha de fin',
'Estado',
'Creado el',
'Actualizado el'
];
}
}