How to export data to CSV?

I see problems on both of your screenshots.

  1. The path must be the path to the file you want to export, like /folder/file.csv
  2. Export data must be a collection/array - in your case the database query.

That’s all. Nothing too complicated at all, as your post makes it look.