I make export classes exportable in the App/Exports like this :
<?php
namespace App\Exports;
use App\Repositories\ItemRepository;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\Exportable;
class ItemsExport implements FromCollection
{
use Exportable;
protected $itemRepository;
public function __construct(ItemRepository $itemRepository)
{
$this->itemRepository = $itemRepository;
}
public function collection()
{
return $this->itemRepository->getItem();
}
}
I call from controller like this :
return (new ItemsExport)->download('items.xlsx');
There exist error like this :
too few arguments to function App\Exports\ItemsExport::__construct(), 0 passed
How can I solve this error?
I get export excel from this tutorial :https://laravel-excel.maatwebsite.nl/docs/3.0/export/basics
new ItemsExport
? – Jerodev