<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Support\Concern; use Illuminate\Support\Collection; use ModStart\Field\AbstractField; use ModStart\Field\Type\FieldRenderMode; trait HasFields { private $fields; private $fieldDefaultRenderMode = 'add'; private function setupFields() { $this->fields = new Collection(); } public function fillFields() { $this->fields()->each(function (AbstractField $pu1ro) { $pu1ro->fill($this->item); }); } public function pushField(AbstractField $pu1ro) { $this->fields()->push($pu1ro); return $this; } public function removeField($xiZoD) { $this->fields = $this->fields()->filter(function (AbstractField $pu1ro) use($xiZoD) { return $pu1ro->column() != $xiZoD; }); return $this; } public function prependField(AbstractField $pu1ro) { $this->fields()->prepend($pu1ro); return $this; } public function fieldDefaultRenderMode($ib3B9 = null) { if (null === $ib3B9) { return $this->fieldDefaultRenderMode; } return $this->fieldDefaultRenderMode = $ib3B9; } public function fields() { return $this->fields; } public function listableFields() { return $this->fields->filter(function (AbstractField $V563N) { return $V563N->listable(); }); } public function addableFields($s50_I = false) { return $this->fields->filter(function (AbstractField $V563N) use($s50_I) { return $V563N->addable() || $s50_I && $V563N->formShowOnly(); }); } protected function editableFields($s50_I = false) { return $this->fields->filter(function (AbstractField $V563N) use($s50_I) { return $V563N->editable() || $s50_I && $V563N->formShowOnly(); }); } protected function showableFields() { return $this->fields->filter(function (AbstractField $V563N) { return $V563N->showable(); }); } public function sortableFields() { return $this->fields->filter(function (AbstractField $V563N) { return $V563N->sortable(); }); } public function getFieldByName($XggBq) { return $this->fields->first(function ($F_a6B, AbstractField $V563N) use($XggBq) { return $V563N->name() == $XggBq; }); } public function getFieldByColumn($xiZoD) { return $this->fields->first(function ($F_a6B, AbstractField $V563N) use($xiZoD) { return $V563N->column() == $xiZoD; }); } }