AppearanceEnable.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Distributor\Actions;
  3. use App\Distributor\Repositories\DistAdminDistributor;
  4. use Dcat\Admin\Grid\RowAction;
  5. use Illuminate\Http\Request;
  6. class AppearanceEnable extends RowAction
  7. {
  8. /**
  9. * 返回字段标题
  10. *
  11. * @return string
  12. */
  13. public function title()
  14. {
  15. return '<i class="feather icon-edit"></i> '.admin_trans_label('enable');
  16. }
  17. public function confirm()
  18. {
  19. $msg = admin_trans_label('confirm_enable_appearance');
  20. return [
  21. $msg,
  22. $this->row->title,
  23. ];
  24. }
  25. /*
  26. * 处理请求
  27. */
  28. public function handle(Request $request)
  29. {
  30. $appearanceId = $this->getKey();
  31. DistAdminDistributor::enableTheme($appearanceId);
  32. // 返回响应结果并刷新页面
  33. return $this->response()->success(admin_trans_label('update_success'))->refresh();
  34. }
  35. /**
  36. * 设置要POST到接口的数据
  37. *
  38. * @return array
  39. */
  40. public function parameters()
  41. {
  42. return [
  43. // 发送当前行 username 字段数据到接口
  44. 'id' => $this->row->title,
  45. ];
  46. }
  47. }