LikeAction.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Admin\Actions\Feeds;
  3. use Dcat\Admin\Grid\RowAction;
  4. use Dcat\Admin\Widgets\Modal;
  5. class LikeAction extends RowAction
  6. {
  7. protected $title;
  8. protected $model;
  9. public function __construct(string $model = null)
  10. {
  11. $this->model = $model;
  12. $this->title = trans('feeds.action.Like_list');
  13. }
  14. /**
  15. * 设置确认弹窗信息,如果返回空值,则不会弹出弹窗
  16. *
  17. * 允许返回字符串或数组类型
  18. *
  19. * @return array|string|void
  20. */
  21. public function confirm()
  22. {
  23. }
  24. /**
  25. * 处理请求
  26. *
  27. * @param Request $request
  28. *
  29. * @return \Dcat\Admin\Actions\Response
  30. */
  31. public function handle(Request $request)
  32. {
  33. return $this->response()
  34. ->success('Processed successfully: '.$this->getKey())
  35. ->redirect('/');
  36. }
  37. /**
  38. * 设置要POST到接口的数据
  39. *
  40. * @return array
  41. */
  42. public function parameters()
  43. {
  44. return [];
  45. }
  46. public function render()
  47. {
  48. $form = LikeList::make()->payload(['id'=>$this->getKey()]);;
  49. return Modal::make()
  50. ->lg()
  51. ->title($this->title)
  52. ->body($form)
  53. ->button('<i class="feather icon-thumbs-up"></i> '.$this->title);
  54. }
  55. }