for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Code4\Forms\Traits;
use Illuminate\Support\Collection;
trait groupFieldTrait {
protected $group = null;
public function group($elements = null) {
if (is_null($this->group)) {
$this->group = new Collection();
}
if (is_null($elements)) {
return $this->group;
if (is_array($elements)) {
foreach ($elements as $fieldName => $fieldValue) {
$newField = \FormsFactory::makeField($this->_type, $fieldName, $fieldValue);
_type
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->group->put($fieldName, $newField);
public function getGroup() {
public function groupChecked($value) {
foreach($this->group as $fieldName => $field) {
$field->checked($value);
return $this;
/**
* Fixes rules for group fields
*/
public function groupRules() {
foreach($this->group as $element) {
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: