RowAction.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace Dcat\Admin\Tree;
  3. use Dcat\Admin\Actions\Action;
  4. class RowAction extends Action
  5. {
  6. /**
  7. * @var \Dcat\Admin\Tree\Actions;
  8. */
  9. protected $actions;
  10. /**
  11. * @var \Illuminate\Database\Eloquent\Model
  12. */
  13. protected $row;
  14. public $selectorPrefix = '.tree-row-action-';
  15. /**
  16. * 获取主键值.
  17. *
  18. * @return array|mixed|string
  19. */
  20. public function getKey()
  21. {
  22. return $this->row->{$this->actions->getParent()->getKeyName()};
  23. }
  24. /**
  25. * 获取行数据.
  26. *
  27. * @return \Illuminate\Database\Eloquent\Model
  28. */
  29. public function getRow()
  30. {
  31. return $this->row;
  32. }
  33. /**
  34. * 获取资源路径.
  35. *
  36. * @return string
  37. */
  38. public function resource()
  39. {
  40. return $this->actions->getParent()->resource();
  41. }
  42. public function getActions()
  43. {
  44. return $this->actions;
  45. }
  46. public function setParent(Actions $actions)
  47. {
  48. $this->actions = $actions;
  49. }
  50. public function setRow($row)
  51. {
  52. $this->row = $row;
  53. }
  54. }