I try to display an excel file with the results from a query. everything is going good till the moment i try to display the dates fields with another format with the following code :
> $licencies->map(function($licencie) {
>
> $licencie['dt_naissance'] = \Carbon\Carbon::createFromFormat('Y-m-d',
> $licencie['dt_naissance'])->format('d/m/y');
I get now an empty excel file . if i remove the code i get the file with the data
I would like to parse only the "dt_naissance" column from the query , someone know how i can achieve this ? thanks a lot in advance
here the full code :
public function build() {
$licencies = Licencies::where('lb_assurance' , '=' , 'Lafont')
->leftJoin('activite_licencie' , 'activite_licencie.id' , '=' , 'licencies.activite_licencie_id')
->leftJoin('saisons' , 'saisons.id' , '=' , 'licencies.saison_id')
->leftJoin('pays' , 'pays.id' , '=' , 'licencies.pays_naissance_id')
->leftJoin('type_licence' , 'type_licence.id' , '=' , 'licencies.type_licence_id')
->leftJoin('structures' , 'structures.id' , '=' , 'licencies.structure_id')
->leftJoin('civilite' , 'civilite.id' , '=' , 'licencies.civilite_id')
->select('civilite.lb_civilite' , 'num_licence' , 'lb_nom' , 'lb_prenom' , 'dt_naissance' , 'pays.fr' ,'activite_licencie.lb_activite' ,'saisons.lb_saison', 'lb_surclassement' , 'structures.nom_structure' , 'lb_assurance' , 'cd_dept_naissance' , 'lb_adresse' , 'tel_fix_licencie' , 'tel_port_licencie' , 'adresse_email' , 'licencies.created_at')
//->whereRaw('DATE(licencies.created_at) = CURRENT_DATE')
->get();
$licencies->map(function($licencie) {
$licencie['dt_naissance'] = \Carbon\Carbon::createFromFormat('Y-m-d', $licencie['dt_naissance'])->format('d/m/y');
});
$excel_file = Excel::create('DailyRecapLicencesLafont', function($excel) use ($licencies) {
$excel->sheet('Excel', function($sheet) use ($licencies)
{
$sheet->fromArray($licencies);
});
});
via Mathieu Mourareau