how to export using laravel excel with calling mysql stored procedure?

  laravel, laravel-excel, mysql, php, stored-procedures

I’m trying to export my pivoted attendance data using Maatwebsite/LaravelExcel, and I use mysql stored procedure to retrieve the pivoted data, but I’m having some problems, how can I export my data using my query stored procedure? I haven’t found a solution to this problem, or should I change my query to eloquent form so that it matches the method documentation at https://docs.laravel-excel.com/3.1/exports/from-query.html, or is there another solution for this problem ?, here is my work

tbl_attendances

   date            lat                long         user_id      image            created_at 
===================================================================================================
2020-09-16     -6.8517888         107.4987008         1      1590688525.jpg     2020-09-16 11:55:25
2020-09-16     -6.8517888         107.4987008         2      1590725637.jpg     2020-09-16 11:55:25
2020-09-16     -6.8517888         107.4987008         3      1590725723.jpg     2020-09-16 11:55:25
2020-09-16     -6.8517888         107.4987008         4      1590726094.jpg     2020-09-16 11:55:25
2020-09-16     -6.8517888         107.4987008         5      1590726264.jpg     2020-09-16 11:55:25
xxxx           xxxx               xxxx                x      xxxx               xxxx
xxxx           xxxx               xxxx                x      xxxx               xxxx
xxxx           xxxx               xxxx                x      xxxx               xxxx

AttendanceQueryExport.php -> https://i.stack.imgur.com/co0C0.png

Mysql Stored Procedure Queries -> https://i.stack.imgur.com/iRsXh.png

Example Result From Queries -> https://i.stack.imgur.com/HgKuH.png

When I try to export with the code above, I get an error like this -> https://i.stack.imgur.com/doRVh.png

Source: Laravel

Leave a Reply