<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Support\Concern; use Illuminate\Support\Collection; use ModStart\Field\AbstractField; use ModStart\Field\CascadeGroup; use ModStart\Field\Html; 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 $Q2vn5) { $Q2vn5->fill($this->item); }); } public function pushField(AbstractField $Q2vn5) { $this->fields()->push($Q2vn5); return $this; } public function prependField(AbstractField $Q2vn5) { $this->fields()->prepend($Q2vn5); return $this; } public function fieldDefaultRenderMode($tzAUI = null) { if (null === $tzAUI) { return $this->fieldDefaultRenderMode; } return $this->fieldDefaultRenderMode = $tzAUI; } public function fields() { return $this->fields; } public function listableFields() { return $this->fields->filter(function (AbstractField $Nrp0b) { return $Nrp0b->listable(); }); } public function addableFields() { return $this->fields->filter(function (AbstractField $Nrp0b) { return $Nrp0b->addable(); }); } protected function editableFields() { return $this->fields->filter(function (AbstractField $Nrp0b) { return $Nrp0b->editable(); }); } protected function showableFields() { return $this->fields->filter(function (AbstractField $Nrp0b) { return $Nrp0b->showable(); }); } public function sortableFields() { return $this->fields->filter(function (AbstractField $Nrp0b) { return $Nrp0b->sortable(); }); } }