App\services\OptionForm::render PHP Method

render() public method

public render ( )
    public function render()
    {
        if (!is_null($this->alwaysCallback)) {
            call_user_func($this->alwaysCallback, $this);
        }
        foreach ($this->items as $item) {
            $id = $item->id;
            if (!($value = $item->get('value'))) {
                preg_match('/(.*)\\[(.*)\\]/', $id, $matches);
                if (isset($matches[2])) {
                    $option = @unserialize(option($matches[1]));
                    $value = Arr::get($option, $matches[2]);
                } else {
                    $value = option($item->id);
                }
            }
            switch ($item->type) {
                case 'text':
                    $view = view('vendor.option-form.text')->with(compact('id', 'value'));
                    break;
                case 'checkbox':
                    $view = view('vendor.option-form.checkbox')->with(['id' => $id, 'label' => $item->get('label'), 'checked' => (bool) $value]);
                    break;
                case 'select':
                case 'textarea':
                case 'group':
                    $view = $item->get('view')->render();
                    break;
            }
            $item->setContent($view->render());
        }
        return view('vendor.option-form.main')->with(get_object_vars($this))->render();
    }