Delete.php 917 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Dcat\Admin\Grid\Actions;
  3. use Dcat\Admin\Grid\RowAction;
  4. use Dcat\Admin\Support\Helper;
  5. class Delete extends RowAction
  6. {
  7. /**
  8. * @return array|null|string
  9. */
  10. public function title()
  11. {
  12. if ($this->title) {
  13. return $this->title;
  14. }
  15. return '<i class="feather icon-trash"></i> '.__('admin.delete');
  16. }
  17. public function render()
  18. {
  19. $this->setHtmlAttribute([
  20. 'data-url' => $this->url(),
  21. 'data-message' => "ID - {$this->getKey()}",
  22. 'data-action' => 'delete',
  23. 'data-redirect' => $this->redirectUrl(),
  24. ]);
  25. return parent::render();
  26. }
  27. protected function redirectUrl()
  28. {
  29. return $this->parent->model()->withoutTreeQuery(request()->fullUrl());
  30. }
  31. public function url()
  32. {
  33. return "{$this->resource()}/{$this->getKey()}";
  34. }
  35. }