<?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($gP2DQ, $g_1Yr = 12) { if ($gP2DQ instanceof \Closure) { call_user_func($gP2DQ, $this); } else { $this->append($gP2DQ); } if (is_null($g_1Yr) || is_array($g_1Yr) && count($g_1Yr) === 0) { $this->width['md'] = 12; } elseif (is_numeric($g_1Yr)) { $this->width['md'] = $g_1Yr; } else { $this->width = $g_1Yr; } } public function append($gP2DQ) { $this->contents[] = $gP2DQ; return $this; } public function row($gP2DQ) { goto FxdqU; FxdqU: if (!$gP2DQ instanceof \Closure) { $tEaF3 = new Row($gP2DQ); } else { $tEaF3 = new Row(); call_user_func($gP2DQ, $tEaF3); } goto UXkt6; UXkt6: ob_start(); goto hFOnf; XnsMv: ob_end_clean(); goto L5ea9; gMsXd: $jMvVI = ob_get_contents(); goto XnsMv; hFOnf: $tEaF3->build(); goto gMsXd; L5ea9: return $this->append($jMvVI); goto RzG0D; RzG0D: } public function build() { goto dK2BQ; FICns: $this->endColumn(); goto BVvB5; SzmSf: foreach ($this->contents as $gP2DQ) { if ($gP2DQ instanceof Renderable || $gP2DQ instanceof Grid) { echo $gP2DQ->render(); } else { echo (string) $gP2DQ; } } goto FICns; dK2BQ: $this->startColumn(); goto SzmSf; BVvB5: } protected function startColumn() { $rTMUX = collect($this->width)->map(function ($cBDsM, $oMJcb) { return $oMJcb ? "col-{$oMJcb}-{$cBDsM}" : "col-{$cBDsM}"; })->implode(' '); echo "<div class=\"{$rTMUX}\">"; } protected function endColumn() { echo '</div>'; } }