src/Traits/Module/HasForm.php
protected function scaffoldForm()
    {
        $editable = new Mutable();

        if ($eloquent = $this->model()) {
            $editable = $editable
                ->merge($translatable = $this->scaffoldTranslatable($eloquent))
                ->merge($eloquent->getFillable());

            return $editable->map(function ($name) use ($eloquent, $translatable) {
                $formElement = InputFactory::make(
                    $name,
                    $this->inputType($name, $eloquent)
                );

                if (in_array($name, $translatable, true)) {
                    $formElement->setTranslatable(true);
                }

                // For Enums (Select|Radio) try to extract values from database.
                if (is_a($formElement, Select::class)
                    && empty($formElement->getOptions())
                    && connection('mysql')
                ) {
                    $formElement->setOptions(
                        $values = enum_values($table = $eloquent->getTable(), $name)
                    );

                    // set appropriate styling
                    if (count($values) > 5) {
                        $formElement->setStyle([
                            'display' => 'block',
                        ]);
                    }

                    // set default value
                    if ($default = scheme()->columns($table)[$name]->getDefault()) {
                        $formElement->setValue($default);
                    }
                }

                $container = new FormElement($name);

                return $container->setInput($formElement);
            });
        }

        return $editable;
    }
protected function scaffoldForm()
    {
        $editable = new Mutable();

        if ($eloquent = $this->model()) {
            $editable = $editable
                ->merge($translatable = $this->scaffoldTranslatable($eloquent))
                ->merge($eloquent->getFillable());

            return $editable->map(function ($name) use ($eloquent, $translatable) {
                $formElement = InputFactory::make(
                    $name,
                    $this->inputType($name, $eloquent)
                );

                if (in_array($name, $translatable, true)) {
                    $formElement->setTranslatable(true);
                }

                // For Enums (Select|Radio) try to extract values from database.
                if (is_a($formElement, Select::class)
                    && empty($formElement->getOptions())
                    && connection('mysql')
                ) {
                    $formElement->setOptions(
                        $values = enum_values($table = $eloquent->getTable(), $name)
                    );

                    // set appropriate styling
                    if (count($values) > 5) {
                        $formElement->setStyle([
                            'display' => 'block',
                        ]);
                    }

                    // set default value
                    if ($default = scheme()->columns($table)[$name]->getDefault()) {
                        $formElement->setValue($default);
                    }
                }

                $container = new FormElement($name);

                return $container->setInput($formElement);
            });
        }

        return $editable;
    }
protected function scaffoldForm ( ) { $ editable = new Mutable ( ) ; if ( $ eloquent = $ this -> model ( ) ) { $ editable = $ editable -> merge ( $ translatable = $ this -> scaffoldTranslatable ( $ eloquent ) ) -> merge ( $ eloquent -> getFillable ( ) ) ; return $ editable -> map ( function ( $ name ) use ( $ eloquent , $ translatable ) { $ formElement = InputFactory :: make ( $ name , $ this -> inputType ( $ name , $ eloquent ) ) ; if ( in_array ( $ name , $ translatable , true ) ) { $ formElement -> setTranslatable ( true ) ; } // For Enums (Select|Radio) try to extract values from database. if ( is_a ( $ formElement , Select :: class ) && empty ( $ formElement -> getOptions ( ) ) && connection ( 'mysql' ) ) { $ formElement -> setOptions ( $ values = enum_values ( $ table = $ eloquent -> getTable ( ) , $ name ) ) ; // set appropriate styling if ( count ( $ values ) > 5 ) { $ formElement -> setStyle ( [ 'display' => 'block' , ] ) ; } // set default value if ( $ default = scheme ( ) -> columns ( $ table ) [ $ name ] -> getDefault ( ) ) { $ formElement -> setValue ( $ default ) ; } } $ container = new FormElement ( $ name ) ; return $ container -> setInput ( $ formElement ) ; } ) ; } return $ editable ; }
Build editable columns based on table columns metadata.

@return Mutable
Build editable columns based on table columns metadata .