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