<commit_before><?php
/**
 * Code generated using LaraAdmin
 * Help: http://laraadmin.com
 * LaraAdmin is open-sourced software licensed under the MIT license.
 * Developed by: Dwij IT Solutions
 * Developer Website: http://dwijitsolutions.com
 */

namespace Dwij\Laraadmin;

use Schema;
use Collective\Html\FormFacade as Form;
use Dwij\Laraadmin\Models\Module;
use Dwij\Laraadmin\Models\ModuleFieldTypes;

/**
 * Class LAFormMaker
 * @package Dwij\Laraadmin
 *
 * This class is blade directive implementation for Form Elements in Module as well as other utilities
 * for Access Control. It also has method process_values which processes fields data from its context.
 *
 */
class LAFormMaker
{
    /**
     * Print input field enclosed within form.
     *
     * Uses blade syntax @la_input('name')
     *
     * @param $module Module Object
     * @param $field_name Field Name for which input has be created
     * @param null $default_val Default Value of Field. This will override default value from context.
     * @param null $required2 Is this field mandatory.
     * @param string $class Custom css class. Default would be bootstrap 'form-control' class
     * @param array $params Additional Parameters for Customization
     * @return string This return html string with field inputs
     */
    public static function input($module, $field_name, $default_val = null, $required2 = null, $class = 'form-control', $params = [])
    {
        // Check Field Write Aceess
        if(Module::hasFieldAccess($module->id, $module->fields[$field_name]['id'], $access_type = "write")) {
            $allow_edit = Module::hasAccess($module->id,'edit');
            if(!$allow_edit){
                $params['disable']  = 'disable';
            }
            $row = null;
            if(isset($module->row)) {
                $row = $module->row;
            }

            //print_r($module->fields);
            $label = $module->fields[$field_name]['label'];
            $field_type = $module->fields[$field_name]['field_type'];
            $unique = $module->fields[$field_name]['unique'];
            $defaultvalue = $module->fields[$field_name]['defaultvalue'];
            $minlength = $module->fields[$field_name]['minlength'];
            $maxlength = $module->fields[$field_name]['maxlength'];
            $required = $module->fields[$field_name]['required'];
            $popup_vals = $module->fields[$field_name]['popup_vals'];

            if($required2 != null) {
                $required = $required2;
            }

            $field_type = ModuleFieldTypes::find($field_type);

            $out = '<div class="form-group">';
            $required_ast = "";

            $params['id'] = $field_name;

            if(!isset($params['class'])) {
                $params['class'] = $class;
            }
            if(!isset($params['placeholder'])) {
                $params['placeholder'] = 'Enter ' . $label;
            }
            if(isset($minlength)) {
                $params['data-rule-minlength'] = $minlength;
            }
            if(isset($maxlength)) {
                $params['data-rule-maxlength'] = $maxlength;
            }
            if($unique && !isset($params['unique'])) {
                $params['data-rule-unique'] = "true";
                $params['field_id'] = $module->fields[$field_name]['id'];
                $params['adminRoute'] = config('laraadmin.adminRoute');
                if(isset($row)) {
                    $params['isEdit'] = true;
                    $params['row_id'] = $row->id;
                } else {
                    $params['isEdit'] = false;
                    $params['row_id'] = 0;
                }
                $out .= '<input type="hidden" name="_token_' . $module->fields[$field_name]['id'] . '" value="' . csrf_token() . '">';
            }

            if($required && !isset($params['required'])) {
                $params['required'] = $required;
                $required_ast = "*";<commit_msg>Basic changes to the input collection if uqiuce<commit_after><?php
/**
 * Code generated using LaraAdmin
 * Help: http://laraadmin.com
 * LaraAdmin is open-sourced software licensed under the MIT license.
 * Developed by: Dwij IT Solutions
 * Developer Website: http://dwijitsolutions.com
 */

namespace Dwij\Laraadmin;

use Schema;
use Collective\Html\FormFacade as Form;
use Dwij\Laraadmin\Models\Module;
use Dwij\Laraadmin\Models\ModuleFieldTypes;

/**
 * Class LAFormMaker
 * @package Dwij\Laraadmin
 *
 * This class is blade directive implementation for Form Elements in Module as well as other utilities
 * for Access Control. It also has method process_values which processes fields data from its context.
 *
 */
class LAFormMaker
{
    /**
     * Print input field enclosed within form.
     *
     * Uses blade syntax @la_input('name')
     *
     * @param $module Module Object
     * @param $field_name Field Name for which input has be created
     * @param null $default_val Default Value of Field. This will override default value from context.
     * @param null $required2 Is this field mandatory.
     * @param string $class Custom css class. Default would be bootstrap 'form-control' class
     * @param array $params Additional Parameters for Customization
     * @return string This return html string with field inputs
     */
    public static function input($module, $field_name, $default_val = null, $required2 = null, $class = 'form-control', $params = [])
    {
        // Check Field Write Aceess
        if(Module::hasFieldAccess($module->id, $module->fields[$field_name]['id'], $access_type = "write")) {
            $allow_edit = Module::hasAccess($module->id,'edit');
            if(!$allow_edit){
                $params['disable']  = 'disable';
            }
            $row = null;
            if(isset($module->row)) {
                $row = $module->row;
            }

            //print_r($module->fields);
            $label = $module->fields[$field_name]['label'];
            $field_type = $module->fields[$field_name]['field_type'];
            $unique = $module->fields[$field_name]['unique'];
            $defaultvalue = $module->fields[$field_name]['defaultvalue'];
            $minlength = $module->fields[$field_name]['minlength'];
            $maxlength = $module->fields[$field_name]['maxlength'];
            $required = $module->fields[$field_name]['required'];
            $popup_vals = $module->fields[$field_name]['popup_vals'];

            if($required2 != null) {
                $required = $required2;
            }

            $field_type = ModuleFieldTypes::find($field_type);

            $out = '<div class="form-group">';
            $required_ast = "";

            $params['id'] = $field_name;

            if(!isset($params['class'])) {
                $params['class'] = $class;
            }
            if(!isset($params['placeholder'])) {
                $params['placeholder'] = 'Enter ' . $label;
            }
            if(isset($minlength)) {
                $params['data-rule-minlength'] = $minlength;
            }
            if(isset($maxlength)) {
                $params['data-rule-maxlength'] = $maxlength;
            }
            if($unique && !isset($params['unique'])) {
                $params['data-rule-unique'] = "true";
                $params['field_id'] = $module->fields[$field_name]['id'];
                $params['adminRoute'] = config('laraadmin.adminRoute');
                if(isset($row)) {
                    $params['isEdit'] = true;
                    if(isset($row[0])){
                        $params['row_id'] = $row[0]->id;
                    }
                    else{
                        $params['row_id'] = $row->id;
                    }
                } else {
                    $params['isEdit'] = false;
                    $params['row_id'] = 0;
                }
                $out .= '<input type="hidden" name="_token_' . $module->fields[$field_name]['id'] . '" value="' . csrf_token() . '">';
            }

            if($required && !isset($params['required'])) {
                $params['required'] = $required;
                $required_ast = "*";
{'fraction_non_alphanumeric': 0.14683946692749725, 'fraction_numerical': 0.0014671720259200392, 'mean_word_length': 2.119755911517925, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5131734', 'n_tokens_mistral': 2248, 'n_tokens_neox': 2171, 'n_words': 507}