<?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($Afv_G, $NxzmO = 12) { if ($Afv_G instanceof \Closure) { call_user_func($Afv_G, $this); } else { $this->append($Afv_G); } if (is_null($NxzmO) || is_array($NxzmO) && count($NxzmO) === 0) { $this->width['md'] = 12; } elseif (is_numeric($NxzmO)) { $this->width['md'] = $NxzmO; } else { $this->width = $NxzmO; } } public function append($Afv_G) { $this->contents[] = $Afv_G; return $this; } public function row($Afv_G) { goto xqK0c; xqK0c: if (!$Afv_G instanceof \Closure) { $tMM4T = new Row($Afv_G); } else { $tMM4T = new Row(); call_user_func($Afv_G, $tMM4T); } goto mskdi; MvjK2: $tMM4T->build(); goto URNjG; mskdi: ob_start(); goto MvjK2; fSFum: return $this->append($q4YT4); goto Utzn1; kf9l8: ob_end_clean(); goto fSFum; URNjG: $q4YT4 = ob_get_contents(); goto kf9l8; Utzn1: } public function build() { goto DXqma; a9T39: $this->endColumn(); goto clYow; DXqma: $this->startColumn(); goto jSe_J; jSe_J: foreach ($this->contents as $Afv_G) { if ($Afv_G instanceof Renderable || $Afv_G instanceof Grid) { echo $Afv_G->render(); } else { echo (string) $Afv_G; } } goto a9T39; clYow: } protected function startColumn() { $uS8I4 = collect($this->width)->map(function ($Gttsd, $jPfeB) { return $jPfeB ? "col-{$jPfeB}-{$Gttsd}" : "col-{$Gttsd}"; })->implode(' '); echo "<div class=\"{$uS8I4}\">"; } protected function endColumn() { echo '</div>'; } }