Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
91 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace VoyagerExcel\Actions; | ||
|
||
use TCG\Voyager\Actions\AbstractAction; | ||
use Maatwebsite\Excel\Facades\Excel; | ||
use VoyagerExcel\Exports\PostExport; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Export extends AbstractAction | ||
{ | ||
public function getTitle() | ||
{ | ||
return __('voyager_excel::excel.export_excel'); | ||
} | ||
|
||
public function getIcon() | ||
{ | ||
return 'voyager-list'; | ||
} | ||
|
||
public function shouldActionDisplayOnDataType() | ||
{ | ||
if(empty($this->dataType->model_name)){ | ||
return false; | ||
} | ||
if(!class_exists($this->dataType->model_name)){ | ||
return false; | ||
} | ||
$model = new $this->dataType->model_name; | ||
if(!($model instanceof Model)){ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public function getAttributes() | ||
{ | ||
return [ | ||
'class' => 'btn btn-sm btn-primary pull-right', | ||
]; | ||
} | ||
|
||
public function getDefaultRoute() | ||
{ | ||
return null; | ||
} | ||
|
||
|
||
public function massAction($ids, $comingFrom) | ||
{ | ||
if(empty(array_filter($ids))){ | ||
return redirect($comingFrom); | ||
} | ||
return Excel::download(new PostExport($this->dataType, $ids), 'demo-'.date('H:i:s').'.xls'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters