This content originally appeared on CodeSource.io and was authored by Deven
If you are getting call to undefined method maatwebsite\excel\excel::create() error, this article will help you fix the issue.
If you are getting the above error while trying to add providers and aliases like in the code example below:
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"maatwebsite/excel": "^3.1",
"predis/predis": "^1.1",
"uxweb/sweet-alert": "^2.0"
Controller:
use Excel;
public function export_list()
{
Excel::create('Export data', function($excel) {
$excel->sheet('Sheet', function($sheet) {
$data = User::where('city','ygn')->get();
$sheet->fromArray($data);
});
})->download('xls');
}
it can be easily fixed by using Excel::download() or Excel::store(). since ::create has been removed in the latest release.
please note that ALL Laravel Excel 2.* methods are deprecated and will not be able to use in 3.0. Consider the example below:
Excel::load() is removed and replaced by Excel::import($yourImport)
Excel::create() is removed and replaced by Excel::download/Excel::store($yourExport)
Excel::create()->string('xlsx') is removed an replaced by Excel::raw($yourExport, Excel::XLSX)
The post Fix – Call to undefined method maatwebsite\excel\excel::create() appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Deven
Deven | Sciencx (2021-02-26T15:20:08+00:00) Fix – Call to undefined method maatwebsite\excel\excel::create(). Retrieved from https://www.scien.cx/2021/02/26/fix-call-to-undefined-method-maatwebsiteexcelexcelcreate/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.