You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.3 KiB

<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class PrestamosExport implements FromCollection, WithHeadings, WithMapping
{
protected $prestamos;
public function __construct($prestamos = null)
{
$this->prestamos = $prestamos;
}
public function collection()
{
return $this->prestamos;
}
public function headings(): array
{
return [
'ID',
'Solicitante',
'Destino',
'Fecha Salida',
'Fecha Llegada',
'Motivo',
'Domicilio',
'Número de Personas',
'Chofer',
'Estado',
'Fecha Actualización'
];
}
public function map($prestamo): array
{
return [
$prestamo->id,
$prestamo->nombre_solicitante,
$prestamo->destino,
$prestamo->fecha_hora_salida,
$prestamo->fecha_hora_llegada,
$prestamo->motivo,
$prestamo->domicilio,
$prestamo->numero_personas,
$prestamo->chofer ? 'Sí' : 'No',
ucfirst($prestamo->estado),
$prestamo->updated_at->format('d/m/Y H:i')
];
}
}