Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Maria0101's avatar

to export the value of the function in Excel on laravel Nova

to export the value of the function in Excel on laravel Nova

Hi .. There is a ready-made script that uploads data in excel format, from a resource that implements fields and values as well as there is an action that performs the very recording of values in Excel and export.

The value of the field experience is formed (dynamically) that is, it is formed thanks to the function that gives the difference between the record in the database (the date of employment to the date of dismissal or the current timestamp)

Text::make('Стаж', function () { if ($first = $this->employment_date) { $second = $this->dissmissal_date ?? Carbon::today(); return ru_year_month_interval($first->diffInMonths($second)); } return ''; })->OnlyOnDetail(),

At the entrance of the action serves the values as arrays of real field values from the database , the code resource posted on Google drive : https://drive.google.com/file/d/1fdLK3UuV9Y2B_23sqF2OD5FOkoBBiPiK/view?usp=sharing

Actually I made that the names of the column Experience in excel were displayed at export, near other columns, but for some reason values in the form of a time interval (experience) fields will not be filled !

I tried to pass the result of the function in the form of an array, but nothing happens the experience values in Excel are not filled !!! Dear forum members tell me how to transfer the value of the function-to enter the action to fill in the values in the excel table field experience? Thanks

Code Action place on Google drive https://drive.google.com/file/d/1A_Hzplj-FJaFkHb8si8ckli7sTX--00C/view?usp=sharing

0 likes
1 reply

Please or to participate in this conversation.