<?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 $Ldet7) { $Ldet7->fill($this->item); }); } public function pushField(AbstractField $Ldet7) { $this->fields()->push($Ldet7); return $this; } public function removeField($GR5Ef) { $this->fields = $this->fields()->filter(function (AbstractField $Ldet7) use($GR5Ef) { return $Ldet7->column() != $GR5Ef; }); return $this; } public function prependField(AbstractField $Ldet7) { $this->fields()->prepend($Ldet7); return $this; } public function fieldDefaultRenderMode($cBDsM = null) { if (null === $cBDsM) { return $this->fieldDefaultRenderMode; } return $this->fieldDefaultRenderMode = $cBDsM; } public function fields() { return $this->fields; } public function listableFields() { return $this->fields->filter(function (AbstractField $P1uVJ) { return $P1uVJ->listable(); }); } public function addableFields($RiB61 = false) { return $this->fields->filter(function (AbstractField $P1uVJ) use($RiB61) { return $P1uVJ->addable() || $RiB61 && $P1uVJ->formShowOnly(); }); } protected function editableFields($RiB61 = false) { return $this->fields->filter(function (AbstractField $P1uVJ) use($RiB61) { return $P1uVJ->editable() || $RiB61 && $P1uVJ->formShowOnly(); }); } protected function showableFields() { return $this->fields->filter(function (AbstractField $P1uVJ) { return $P1uVJ->showable(); }); } public function sortableFields() { return $this->fields->filter(function (AbstractField $P1uVJ) { return $P1uVJ->sortable(); }); } public function getFieldByName($glP3G) { return $this->fields->first(function ($lxIPA, AbstractField $P1uVJ) use($glP3G) { return $P1uVJ->name() == $glP3G; }); } public function getFieldByColumn($GR5Ef) { return $this->fields->first(function ($lxIPA, AbstractField $P1uVJ) use($GR5Ef) { return $P1uVJ->column() == $GR5Ef; }); } }