Skip to content

Commit

Permalink
Export
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Oct 1, 2020
1 parent 047b483 commit e3b4994
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/Exports/PlacesExport.php → src/Exports/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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,
];
}

Expand All @@ -57,7 +57,6 @@ public function headings(): array
'email',
'website',
'phone',
'fax',
'latitude',
'longitude',
'title',
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit e3b4994

Please sign in to comment.