HasLayout.php 628 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Dcat\Admin\Form\Concerns;
  3. use Closure;
  4. use Dcat\Admin\Form\Layout;
  5. trait HasLayout
  6. {
  7. /**
  8. * @var Layout
  9. */
  10. protected $layout;
  11. /**
  12. * @param int|float $width
  13. * @param Closure $callback
  14. *
  15. * @return $this
  16. */
  17. public function column($width, Closure $callback)
  18. {
  19. $this->layout()->onlyColumn($width, function () use ($callback) {
  20. $callback($this);
  21. });
  22. return $this;
  23. }
  24. /**
  25. * @return Layout
  26. */
  27. public function layout()
  28. {
  29. return $this->layout ?: ($this->layout = new Layout($this));
  30. }
  31. }