private function groupLabel()
 {
     Form::macro('group_label', function ($name, $label) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         return '<div class="control-group">
                     <label for="title" class="control-label">' . $label . '</label>
                     <div class="controls">
                         <label for="title" class="control-label">' . $value . '</label>
                     </div>
                 </div>';
     });
 }
 private function extendForm()
 {
     Form::macro('parse', function ($array) {
         $fields = ['placeholder', 'percent', 'modal', 'label_col'];
         $arr = [];
         foreach ($fields as $field) {
             if (array_key_exists($field, $array)) {
                 $arr[$field] = $array[$field];
             } else {
                 $arr[$field] = '';
             }
         }
         return $arr;
     });
     Form::macro('group_label', function ($name, $label) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         return '<div class="control-group">
                     <label for="title" class="control-label">' . $label . '</label>
                     <div class="controls">
                         <label for="title" class="control-label">' . $value . '</label>
                     </div>
                 </div>';
     });
     Form::macro('hidden_input', function ($name, $value = '') {
         return '<input type="hidden" value="' . $value . '" name="' . $name . '" id="' . $name . '">';
     });
     Form::macro('group_text', function ($name, $label, $placeholder = '', $percent = 0.5, $modal = false) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         $data = '';
         $input_col = 9;
         if (is_array($placeholder)) {
             $data = Form::parse($placeholder);
             $placeholder = $data['placeholder'];
             $percent = $data['percent'] ? $data['percent'] : 0.5;
             $modal = $data['modal'] ? true : false;
             $input_col = $data['label_col'] ? 12 - $data['label_col'] : 9;
         }
         $style = $modal ? 'style="padding:0px"' : '';
         return '<div class="form-group col-sm-' . $percent * 12 . '" ' . $style . '>
                     ' . Form::form_label($label, $data) . '
                     <div class="col-sm-' . $input_col . '">
                         <input name="' . $name . '" type="text" value="' . $value . '" class="form-control" placeholder="' . $placeholder . '">
                       </div>
                 </div>';
     });
     Form::macro('group_password', function ($name, $label, $placeholder = '', $percent = 0.5, $modal = false) {
         $data = '';
         $input_col = 9;
         if (is_array($placeholder)) {
             $data = Form::parse($placeholder);
             $placeholder = $data['placeholder'];
             $percent = $data['percent'] ? $data['percent'] : 0.5;
             $modal = $data['modal'] ? true : false;
             $input_col = $data['label_col'] ? 12 - $data['label_col'] : 9;
         }
         $style = $modal ? 'style="padding:0px"' : '';
         return '<div class="form-group col-sm-' . $percent * 12 . '" ' . $style . '>
                     ' . Form::form_label($label, $data) . '
                     <div class="col-sm-' . $input_col . '">
                         <input name="' . $name . '" type="password" class="form-control" placeholder="' . $placeholder . '">
                       </div>
                 </div>';
     });
     Form::macro('group_area', function ($name, $label, $placeholder = '', $percent = 0.5) {
         $value = $this->model && (!is_array($this->model) || array_key_exists($name, $this->model)) ? $this->model[$name] : '';
         $data = '';
         $input_col = 9;
         $modal = false;
         if (is_array($placeholder)) {
             $data = Form::parse($placeholder);
             $placeholder = $data['placeholder'];
             $percent = $data['percent'] ? $data['percent'] : 0.5;
             $modal = $data['modal'] ? true : false;
             $input_col = $data['label_col'] ? 12 - $data['label_col'] : 9;
         }
         $style = $modal ? 'style="padding:0px"' : '';
         return '<div class="form-group col-sm-' . $percent * 12 . '" ' . $style . '>
                     ' . Form::form_label($label, $data) . '
                     <div class="col-sm-' . $input_col . '">
                         <textarea id="' . $name . '" name="' . $name . '" rows="6" class="form-control" placeholder="' . $placeholder . '">' . $value . '</textarea>
                     </div>
                 </div>';
     });
     Form::macro('group_radio', function ($name, $label, $data, $percent = 1) {
         $result = '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9">';
         foreach ($data as $item) {
             if ($this->model) {
                 $checked = $this->model[$name] == $item[0] ? 'checked=true' : '';
             } else {
                 $checked = sizeof($item) == 3 ? 'checked=' . $item[2] : '';
             }
             $result .= '<input ' . $checked . '" name="' . $name . '" type="radio" value="' . $item[0] . '">
                         <span style="vertical-align: middle;padding-right:10px">' . $item[1] . '</span>';
         }
         return $result . '</div></div>';
     });
     Form::macro('group_checkbox', function ($name, $label, $data, $percent = 1) {
         $result = '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9">';
         foreach ($data as $item) {
             if ($this->model) {
                 $checked = $this->model[$name] == $item[0] ? 'checked=true' : '';
             } else {
                 $checked = sizeof($item) == 3 ? 'checked=' . $item[2] : '';
             }
             $result .= '<label class="checkbox-inline">';
             $result .= '<input ' . $checked . '" name="' . $name . '" type="checkbox" value="' . $item[0] . '">
                         <span style="vertical-align: middle;padding-right:10px">' . $item[1] . '</span>';
             $result .= '</label>';
         }
         return $result . '</div></div>';
     });
     Form::macro('form_action', function ($label) {
         return '<div class="form-group col-sm-12">
                     <button class="btn btn-fw btn-primary" type="submit">' . $label . '</button>
                 </div>';
     });
     Form::macro('modal_button', function ($label, $modal, $data, $class = 'waves-effect') {
         $test = json_encode($data);
         $html = '<a href="' . $modal . '" style="margin-left:5px;"><button onclick="fillModal(\'' . $data->id . '\')" class="btn ' . $class . '" >' . $label . '</button></a>';
         $js = "<script>init.push(function(){datas['" . $data->id . "']='" . $test . "';})</script>";
         return $html . $js;
     });
     Form::macro('form_button', function ($config, $data) {
         if (!array_key_exists('alert', $config)) {
             $config['alert'] = '确认吗?';
         }
         if (!array_key_exists('uri', $config)) {
             $config['uri'] = 'update';
         }
         if (!array_key_exists('class', $config)) {
             $config['class'] = 'btn-default';
         }
         if (!array_key_exists('method', $config)) {
             $config['method'] = 'POST';
         }
         if ($config['method'] == 'POST') {
             $dataInputs = '';
             foreach ($data as $key => $value) {
                 $dataInputs .= '<input type="hidden" name="' . $key . '" value="' . $value . '">';
             }
             $result = '<form style="float: left;margin-right: 5px;" action="' . $this->url->current() . '/' . $config['uri'] . '" method="POST">
              <input type="hidden" name="id" value="' . $config['id'] . '">
              <input type="hidden" name="_method" value="PATCH">
              ' . $dataInputs . '
              ' . Form::token() . '
              <button type="submit" class="btn ' . $config['class'] . '" onclick="return confirm(\'' . $config['alert'] . '\')" >' . $config['name'] . '</button>
              </form>';
         } else {
             $result = '<a href="' . $this->url->current() . '/' . $config['uri'] . '"><button type="submit" class="btn ' . $config['class'] . '">' . $config['name'] . '</button></a>';
         }
         return $result;
     });
     Form::macro('form_label', function ($label, $modal = false) {
         $col = 3;
         if (is_array($modal)) {
             $col = $modal['label_col'] ? $modal['label_col'] : 3;
             $modal = $modal['modal'];
         }
         $style = $modal ? 'style="padding: 7px 0px;"' : '';
         return '<label class="col-sm-' . $col . ' control-label" ' . $style . '>' . $label . '</label>';
     });
     Form::macro('form_select', function ($name, $label, $data, $percent = 0.5) {
         $result = '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9"><select class="form-control" name="' . $name . '">';
         foreach ($data as $item) {
             $value = is_array($item) ? $item['value'] : $item;
             $label = is_array($item) ? $item['label'] : $item;
             $selected = '';
             if ($this->model) {
                 $selected = $this->model[$name] == $value ? 'selected="selected"' : '';
             } else {
                 if (is_array($item)) {
                     $selected = sizeof($item) == 3 ? 'selected=' . $item[2] : '';
                 }
             }
             $result .= '<option ' . $selected . ' value="' . $value . '">' . $label . '</option>';
         }
         return $result . '</select></div></div>';
     });
     Form::macro('form_multi_select', function ($name, $label, $data, $percent = 0.5) {
         $result = '<div class="form-group col-lg-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-lg-9"><select multiple class="form-control chzn-select" name="' . $name . '[]">';
         foreach ($data as $item) {
             $value = is_array($item) ? $item['value'] : $item;
             $label = is_array($item) ? $item['label'] : $item;
             $selected = '';
             if ($this->model) {
                 if (isset($this->model[$name])) {
                     $type_ids = explode(',', $this->model[$name]);
                 } else {
                     $type_ids = [];
                 }
                 $result .= '<option ' . (in_array($value, $type_ids) ? 'selected' : '') . ' value="' . $value . '">' . $label . '</option>';
             } else {
                 if (is_array($item)) {
                     $result .= '<option ' . $selected . ' value="' . $value . '">' . $label . '</option>';
                 }
             }
         }
         return $result . '</select></div></div>';
     });
     Form::macro('form_date', function ($name, $label, $placeholder = '', $percent = 0.5) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         if (!is_string($placeholder)) {
             $percent = $placeholder;
         }
         $result = '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9">' . '<input id="' . $name . 'date" name="' . $name . '" type="text" value="' . $value . '" class="form-control" placeholder="' . $placeholder . '">';
         $js = "<script>init.push(function(){jQuery('#" . $name . "date').datetimepicker({format:'Y-m-d'});})</script>";
         return $result . '</div></div>' . $js;
     });
     Form::macro('form_time', function ($name, $label, $placeholder = '', $percent = 0.5) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         if (!is_string($placeholder)) {
             $percent = $placeholder;
         }
         $result = '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9">' . '<input id="' . $name . 'date" name="' . $name . '" type="text" value="' . $value . '" class="form-control" placeholder="' . $placeholder . '">';
         $js = "<script>init.push(function(){jQuery('#" . $name . "date').datetimepicker({format:'Y-m-d H:i'});})</script>";
         return $result . '</div></div>' . $js;
     });
     Form::macro('single_file_upload', function ($name, $label, $percent = 0.5) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         $url = $value ? config('rsct.img_host') . $value : '/admin/img/upload_add.png';
         return '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9">
                         <input id="' . $name . '" type="hidden" name="' . $name . '" type="text" value="' . $value . '">
                         <img style="width:58px;height:58px;cursor:pointer;" id="' . $name . '_img" src="' . $url . '">
                     </div>
                 </div>';
     });
     Form::macro('panel_start', function ($title = '') {
         return '<div class="panel panel-default">
                     <div class="panel-heading bg-white">
                         <span class="font-bold">' . $title . '</span>
                     </div>
                 <div class="panel-body">';
     });
     Form::macro('panel_end', function ($submit_label = '') {
         if (!$submit_label) {
             return '';
         }
         $result = '</div><footer class="panel-footer">
                         <button type="submit" class="btn btn-info">' . $submit_label . '</button>
                     </footer></div>';
         return $result;
     });
     Form::macro('multi_file_upload', function ($name, $label, $percent = 0.5) {
         $value = ForoneHtmlServiceProvider::parseValue($this->model, $name);
         $url = '/admin/img/upload_add.png';
         $uploaded_items = '';
         if ($value) {
             $items = explode('|', $value);
             foreach ($items as $item) {
                 $details = explode('~', $item);
                 $idvalue = rand() . '';
                 $div = '<div id="' . $idvalue . 'div" style="float:left;width:68px;margin-right: 20px">';
                 if (preg_match("/.pdf/", $details[0])) {
                     $img = '<img onclick="removeMultiUploadItem(\'' . $idvalue . 'div\',\'' . $name . '\')" style="width: 68px; height: 68px;cursor:pointer"
                     src="/admin/img/upload.png">';
                 } else {
                     $img = '<img onclick="removeMultiUploadItem(\'' . $idvalue . 'div\',\'' . $name . '\')" style="width: 68px; height: 68px;cursor:pointer"
                     src="http://img.rsct.com/' . $details[0] . '?imageView2/1/w/68/h/68">';
                 }
                 $uploaded_items .= $div . $img;
                 $v = '';
                 if (sizeof($details) == 2) {
                     $v = "value='{$details['1']}'";
                 }
                 $uploaded_items .= '<input ' . $v . ' type="hidden" onkeyup="fillMultiUploadInput(\'' . $name . '\')" style="width: 68px;float: left" placeholder="图片描述"></div>';
             }
         }
         return '<div class="form-group col-sm-' . $percent * 12 . '">
                     ' . Form::form_label($label) . '
                     <div class="col-sm-9">
                         <input id="' . $name . '" type="hidden" name="' . $name . '" type="text" value="' . $value . '">
                         <img style="width:58px;height:58px;cursor:pointer;float:left;margin-right:20px;" id="' . $name . '_img" src="' . $url . '">
                         <label id="' . $name . '_label"></label>
                         <div id="' . $name . '_div">' . $uploaded_items . '</div>
                     </div>
                 </div>';
     });
 }