/** * Easier arguments order for hidden fields * * @param Container $app The Illuminate Container * @param string $type file * @param string $name Field name * @param string $label Its label * @param string $value Its value * @param array $attributes Attributes */ public function __construct(Container $app, $type, $name, $label, $value, $attributes) { // Multiple files field if ($type == 'files') { $attributes['multiple'] = 'true'; $type = 'file'; $name = $name . '[]'; } parent::__construct($app, $type, $name, $label, $value, $attributes); }
/** * Build a new checkable * * @param Container $app * @param string $type * @param array $name * @param $label * @param $value * @param $attributes */ public function __construct(Container $app, $type, $name, $label, $value, $attributes) { // Unify auto and chained methods of grouping checkboxes if (ends_with($name, '[]')) { $name = substr($name, 0, -2); $this->grouped(); } parent::__construct($app, $type, $name, $label, $value, $attributes); if (is_array($this->value)) { $this->items($this->value); } }
/** * Build an input field * * @param Container $app The Container * @param string $type The input type * @param string $name Field name * @param string $label Its label * @param string $value Its value * @param array $attributes Attributes */ public function __construct(Container $app, $type, $name, $label, $value, $attributes) { parent::__construct($app, $type, $name, $label, $value, $attributes); // Multiple models population if (is_array($this->value)) { $values = array(); foreach ($this->value as $value) { $values[] = is_object($value) ? $value->__toString() : $value; } if (isset($values)) { $this->value = implode(', ', $values); } } }
/** * Easier arguments order for selects * * @param Container $app The Container instance * @param string $type select * @param string $name Field name * @param string $label Its label * @param array $options The select's options * @param string $selected The selected option * @param array $attributes Attributes */ public function __construct(Container $app, $type, $name, $label, $options, $selected, $attributes) { if ($selected) { $this->value = $selected; } if ($options) { $this->options($options); } parent::__construct($app, $type, $name, $label, $selected, $attributes); // Nested models population if (str_contains($this->name, '.') and is_array($this->value) and !empty($this->value) and is_string($this->value[key($this->value)])) { $this->fromQuery($this->value); $this->value = $selected ?: null; } }
/** * Easier arguments order for hidden fields * * @param Container $app The Container * @param string $type hidden * @param string $name Field names * @param string $value Its value * @param array $attributes Attributes */ public function __construct(Container $app, $type, $name, $value, $attributes) { parent::__construct($app, $type, $name, '', $value, $attributes); }