HasRows.php 539 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Dcat\Admin\Form\Concerns;
  3. use Closure;
  4. use Dcat\Admin\Form\Row;
  5. trait HasRows
  6. {
  7. /**
  8. * Field rows in form.
  9. *
  10. * @var Row[]
  11. */
  12. protected $rows = [];
  13. /**
  14. * Add a row in form.
  15. *
  16. * @param Closure $callback
  17. *
  18. * @return $this
  19. */
  20. public function row(Closure $callback)
  21. {
  22. $this->rows[] = new Row($callback, $this);
  23. return $this;
  24. }
  25. /**
  26. * @return Row[]
  27. */
  28. public function rows()
  29. {
  30. return $this->rows;
  31. }
  32. }