Skip to content

Commit

Permalink
Export compatible with swoole
Browse files Browse the repository at this point in the history
  • Loading branch information
never615 committed Jun 15, 2019
1 parent deb7373 commit c3de646
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 8 additions & 0 deletions config/admin.php
Expand Up @@ -345,6 +345,14 @@
*/
'enable_menu_search' => true,


/*
|--------------------------------------------------------------------------
| If your are using swoole, set it to `true`.
|--------------------------------------------------------------------------
*/
'swoole' => env("SWOOLE", false),

/*
|--------------------------------------------------------------------------
| Extension Directory
Expand Down
13 changes: 8 additions & 5 deletions src/Grid.php
Expand Up @@ -187,7 +187,9 @@ public function __construct(Eloquent $model, Closure $builder = null)

$this->initialize();

$this->handleExportRequest();
if (!config('admin.swoole')) {
$this->handleExportRequest();
}

$this->callInitCallbacks();
}
Expand Down Expand Up @@ -234,8 +236,9 @@ protected function callInitCallbacks()
* Handle export request.
*
* @param bool $forceExport
* @return mixed
*/
protected function handleExportRequest($forceExport = false)
public function handleExportRequest($forceExport = false)
{
if (!$scope = request(Exporter::$queryName)) {
return;
Expand All @@ -251,11 +254,11 @@ protected function handleExportRequest($forceExport = false)
if ($this->builder) {
call_user_func($this->builder, $this);

$this->getExporter($scope)->export();
return $this->getExporter($scope)->export();
}

if ($forceExport) {
$this->getExporter($scope)->export();
return $this->getExporter($scope)->export();
}
}

Expand Down Expand Up @@ -363,7 +366,7 @@ protected function addColumn($column = '', $label = '')
$column->setGrid($this);

return tap($column, function ($value) {
$this->columns->push($value);
$this->columns->put($value->getName(), $value);
});
}

Expand Down

0 comments on commit c3de646

Please sign in to comment.