<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Layout; use Illuminate\Contracts\Support\Renderable; use ModStart\Grid\Grid; class Column implements Buildable { protected $width = array(); protected $contents = array(); public function __construct($LTC5O, $jy3JI = 12) { if ($LTC5O instanceof \Closure) { call_user_func($LTC5O, $this); } else { $this->append($LTC5O); } if (is_null($jy3JI) || is_array($jy3JI) && count($jy3JI) === 0) { $this->width['md'] = 12; } elseif (is_numeric($jy3JI)) { $this->width['md'] = $jy3JI; } else { $this->width = $jy3JI; } } public function append($LTC5O) { $this->contents[] = $LTC5O; return $this; } public function row($LTC5O) { goto TdIRU; tSwkx: return $this->append($KNNx8); goto YWi1k; TdIRU: if (!$LTC5O instanceof \Closure) { $KWrRN = new Row($LTC5O); } else { $KWrRN = new Row(); call_user_func($LTC5O, $KWrRN); } goto MAgBw; MI3zy: $KWrRN->build(); goto R68Is; zBjJR: ob_end_clean(); goto tSwkx; MAgBw: ob_start(); goto MI3zy; R68Is: $KNNx8 = ob_get_contents(); goto zBjJR; YWi1k: } public function build() { goto gIqTJ; Gt9ia: foreach ($this->contents as $LTC5O) { if ($LTC5O instanceof Renderable || $LTC5O instanceof Grid) { echo $LTC5O->render(); } else { echo (string) $LTC5O; } } goto yuKQE; gIqTJ: $this->startColumn(); goto Gt9ia; yuKQE: $this->endColumn(); goto x5vjw; x5vjw: } protected function startColumn() { $QMs0F = collect($this->width)->map(function ($mdHu1, $HQKqq) { return $HQKqq ? "col-{$HQKqq}-{$mdHu1}" : "col-{$mdHu1}"; })->implode(' '); echo "<div class=\"{$QMs0F}\">"; } protected function endColumn() { echo '</div>'; } }