public function updateProductOption()
 {
     if (!Request::ajax()) {
         return App::abort(404);
     }
     $arrReturn = ['status' => 'error'];
     if (Input::has('pk')) {
         $id = (int) Input::get('pk');
         $name = (string) Input::get('name');
         $value = e((string) Input::get('value'));
         try {
             $option = ProductOption::findorFail($id);
             $option->{$name} = $value;
         } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
             return App::abort(404);
         }
     } else {
         $option = new ProductOption();
         $option->name = Input::get('name');
         $option->key = Input::get('key');
         $option->option_group_id = Input::has('option_group_id') ? (int) Input::get('option_group_id') : 0;
     }
     $pass = $option->valid();
     if ($pass->passes()) {
         $option->save();
         $arrReturn = ['status' => 'ok'];
         $arrReturn['message'] = $option->name . ' has been saved';
         $arrReturn['data'] = $option;
     } else {
         $arrReturn['message'] = '';
         $arrErr = $pass->messages()->all();
         foreach ($arrErr as $value) {
             $arrReturn['message'] .= "{$value}\n";
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }