Im using maatwebsite/excel package so according to its doc i created a class eg. PostsExport.php in app/Exports folder.
namespace Demo\Exports;
use Demo\Post;
class PostsExport implements FromCollection
{
public function collection()
{
return Post::all();
}
}
And in my PostController i have the method
use Demo\Exports\PostsExport;
use Maatwebsite\Excel\Facades\Excel;
...
...
public function export()
{
return Excel::download(new PostsExport, 'posts.xlsx');
}
But when i click download button the export method runs but gives error that Demo\Exports\PostsExport not found