You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
59 lines
1.2 KiB
<?php
|
|
|
|
namespace App\AdminSupplier\Actions\Grid;
|
|
|
|
use App\Jobs\ExportProductToExcel;
|
|
use Dcat\Admin\Grid\Tools\AbstractTool;
|
|
use Dcat\Admin\Traits\HasPermissions;
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ExportToExcelButton extends AbstractTool
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected $title = '导入所有产品到excel';
|
|
|
|
public function html()
|
|
{
|
|
$this->appendHtmlAttribute('class', 'btn btn-primary btn-outline');
|
|
|
|
return <<<HTML
|
|
<button {$this->formatHtmlAttributes()}>{$this->title()}</button>
|
|
HTML;
|
|
}
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
ExportProductToExcel::dispatch(\Admin::user()->id);
|
|
return $this->response()->success('导出成功,稍后到导出列表下载');
|
|
}
|
|
|
|
/**
|
|
* @return string|array|void
|
|
*/
|
|
public function confirm()
|
|
{
|
|
// return ['Confirm?', 'contents'];
|
|
}
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function parameters()
|
|
{
|
|
return [];
|
|
}
|
|
}
|