海南旅游SAAS
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

  1. <?php
  2. namespace App\AdminSupplier\Actions\Grid;
  3. use App\Jobs\ExportProductToExcel;
  4. use Dcat\Admin\Grid\Tools\AbstractTool;
  5. use Dcat\Admin\Traits\HasPermissions;
  6. use Illuminate\Contracts\Auth\Authenticatable;
  7. use Illuminate\Database\Eloquent\Model;
  8. use Illuminate\Http\Request;
  9. class ExportToExcelButton extends AbstractTool
  10. {
  11. /**
  12. * @return string
  13. */
  14. protected $title = '导入所有产品到excel';
  15. public function html()
  16. {
  17. $this->appendHtmlAttribute('class', 'btn btn-primary btn-outline');
  18. return <<<HTML
  19. <button {$this->formatHtmlAttributes()}>{$this->title()}</button>
  20. HTML;
  21. }
  22. public function handle(Request $request)
  23. {
  24. ExportProductToExcel::dispatch(\Admin::user()->id);
  25. return $this->response()->success('导出成功,稍后到导出列表下载');
  26. }
  27. /**
  28. * @return string|array|void
  29. */
  30. public function confirm()
  31. {
  32. // return ['Confirm?', 'contents'];
  33. }
  34. /**
  35. * @param Model|Authenticatable|HasPermissions|null $user
  36. *
  37. * @return bool
  38. */
  39. protected function authorize($user): bool
  40. {
  41. return true;
  42. }
  43. /**
  44. * @return array
  45. */
  46. protected function parameters()
  47. {
  48. return [];
  49. }
  50. }