This package quickly export data to Excel or CSV.
You can install the package via composer:
composer require hashcrypt/export
To export data from controller you need to use class,
use Hashcrypt\Export\Export;
To export as Excel,
$data = Model::all()->toarray();
return Export::export($data, 'filename.xlsx');
To export as CSV,
$data = Model::all()->toarray();
return Export::export($data, 'filename.csv');