| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace Dcat\Admin\Layout;
- use Illuminate\Contracts\Support\Renderable;
- class Row implements Renderable
- {
- /**
- * @var Column[]
- */
- protected $columns = [];
- /**
- * Row constructor.
- *
- * @param string $content
- */
- public function __construct($content = '')
- {
- if (! empty($content)) {
- if ($content instanceof Column) {
- $this->addColumn($content);
- } else {
- $this->column(12, $content);
- }
- }
- }
- /**
- * Add a column.
- *
- * @param int $width
- * @param $content
- */
- public function column($width, $content)
- {
- $column = new Column($content, $width);
- $this->addColumn($column);
- }
- /**
- * @param Column $column
- */
- protected function addColumn(Column $column)
- {
- $this->columns[] = $column;
- }
- /**
- * Build row column.
- *
- * @return string
- */
- public function render()
- {
- $html = $this->startRow();
- foreach ($this->columns as $column) {
- $html .= $column->render();
- }
- return $html.$this->endRow();
- }
- /**
- * Start row.
- *
- * @return string
- */
- protected function startRow()
- {
- return '<div class="row">';
- }
- /**
- * End column.
- *
- * @return string
- */
- protected function endRow()
- {
- return '</div>';
- }
- }
|