diff --git a/src/Exports/PlacesExport.php b/src/Exports/Export.php similarity index 83% rename from src/Exports/PlacesExport.php rename to src/Exports/Export.php index 0557d9c..e8e82b1 100644 --- a/src/Exports/PlacesExport.php +++ b/src/Exports/Export.php @@ -14,13 +14,14 @@ use TypiCMS\Modules\Core\Filters\FilterOr; use TypiCMS\Modules\Places\Models\Place; -class PlacesExport implements WithColumnFormatting, ShouldAutoSize, FromCollection, WithHeadings, WithMapping +class Export implements WithColumnFormatting, ShouldAutoSize, FromCollection, WithHeadings, WithMapping { protected $collection; public function __construct($request) { $this->collection = QueryBuilder::for(Place::class) + ->selectFields('created_at,updated_at,status,address,email,website,phone,latitude,longitude,title,summary,body') ->allowedSorts(['id', 'status_translated', 'title_translated']) ->allowedFilters([ AllowedFilter::custom('title', new FilterOr()), @@ -33,17 +34,16 @@ public function map($model): array return [ Date::dateTimeToExcel($model->created_at), Date::dateTimeToExcel($model->updated_at), - $model->status, + $model->status_translated, $model->address, $model->email, $model->website, $model->phone, - $model->fax, $model->latitude, $model->longitude, - $model->title, - $model->summary, - $model->body, + $model->title_translated, + $model->summary_translated, + $model->body_translated, ]; } @@ -57,7 +57,6 @@ public function headings(): array 'email', 'website', 'phone', - 'fax', 'latitude', 'longitude', 'title', diff --git a/src/Http/Controllers/AdminController.php b/src/Http/Controllers/AdminController.php index abf0bec..6265c7e 100644 --- a/src/Http/Controllers/AdminController.php +++ b/src/Http/Controllers/AdminController.php @@ -8,7 +8,7 @@ use Illuminate\View\View; use Maatwebsite\Excel\Facades\Excel; use TypiCMS\Modules\Core\Http\Controllers\BaseAdminController; -use TypiCMS\Modules\Places\Exports\PlacesExport; +use TypiCMS\Modules\Places\Exports\Export; use TypiCMS\Modules\Places\Http\Requests\FormRequest; use TypiCMS\Modules\Places\Models\Place; @@ -23,7 +23,7 @@ public function export(Request $request) { $filename = date('Y-m-d').' '.config('app.name').' places.xlsx'; - return Excel::download(new PlacesExport($request), $filename); + return Excel::download(new Export($request), $filename); } public function create(): View