Jan 12, 2018
0
Level 2
Help with Maatwebsite/Laravel-Excel
I am using Maatwebsite/Laravel-Excel to import excel file into my application. I want to use ExcelFile injections so that I can use it like this in my controller
class ExampleController extends Controller {
public function importUserList(UserListImport $import)
{
// get the results
$results = $import->get();
}
}
In the Maatwebsite/Laravel-Excel example, it says to make a class like this to return and load excel file
class UserListImport extends \Maatwebsite\Excel\Files\ExcelFile {
public function getFile()
{
return storage_path('exports') . '/file.csv';
}
public function getFilters()
{
return [
'chunk'
];
}
}
This method is used to return filename to be imported.
public function getFile()
{
return storage_path('exports') . '/file.csv';
}
My issue is that filename is stored in database and is dynamic. How can I use the Import class with my dynamic filenames.
Docs for Maatwebsite/Laravel-Excel is available at http://www.maatwebsite.nl/laravel-excel/docs/import
Please or to participate in this conversation.