Example #1
0
 public function checkKey()
 {
     $enum_key = Input::get('enum_key');
     $count = Selector::where('enum_key', $enum_key)->count();
     if ($count > 0) {
         return 'false';
     } else {
         return 'true';
     }
 }
Example #2
0
 /**
  * 编辑记录
  * @param $id
  * @return mixed
  */
 public function edit($custom_id = null, $id = null)
 {
     $model = $this->model;
     if (!isset($custom_id) && !isset($id)) {
         $reflectionClass = new \ReflectionClass(config('quickcms.business_user_model_class'));
         $business_user = $reflectionClass->newInstance();
         $business_user = $business_user::where('admin_id', Auth::admin()->get()->id)->first();
         $id = $business_user->business_id;
     }
     $model_data = $model::find(isset($id) ? $id : $custom_id);
     if (!isset($id)) {
         $custom_id = null;
     }
     $data = self::getEditData($model_data, $custom_id);
     $selectors = $data['selectors'];
     $selector_data = [];
     foreach ($selectors as $k => $v) {
         $selector = Selector::where('enum_key', $v)->first();
         $tmp_data = SelectorController::parseSelector($selector->type, $selector->enum_value);
         $tmp_data = (array) json_decode($tmp_data);
         $temp = [];
         foreach ($tmp_data as $key => $value) {
             if (!isset($temp[$selector->default_value])) {
                 $temp[$selector->default_value] = $selector->default_key;
             }
             $temp[$key] = $value;
         }
         $selector_data[$v] = $temp;
     }
     $data['selector_data'] = $selector_data;
     if (isset($business_user)) {
         $data['business_user'] = true;
     }
     $message = Session::get('message');
     $data['message'] = $message;
     return View::make('backend::generals.create', $data);
 }