当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::json方法代码示例

本文整理汇总了PHP中Response::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::json方法的具体用法?PHP Response::json怎么用?PHP Response::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response::json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: requestPageVersionEventUpdate

 /**
  * Requests that a page version event's start and end times
  * be updated
  *
  * @param  int   $id
  * @param  array $input
  * @return Response
  */
 public function requestPageVersionEventUpdate($id, $input)
 {
     $start = array_get($input, 'start');
     $end = array_get($input, 'end');
     $published = array_get($input, 'published', false);
     $event = $this->PageVersionSource->updatePageVersion($id, $start, $end, $published);
     return $this->Response->json($event);
 }
开发者ID:devisephp,项目名称:cms,代码行数:16,代码来源:CalendarResponseHandler.php

示例2: postRestore

 public function postRestore()
 {
     // validasi
     $input = Input::all();
     $rules = array('sql' => 'required|sql');
     $validasi = Validator::make(Input::all(), $rules);
     // tidak valid
     if ($validasi->fails()) {
         // pesan
         $sql = $validasi->messages()->first('sql') ?: '';
         return Response::json(compact('sql'));
         // valid
     } else {
         // ada sql
         if (Input::hasFile('sql')) {
             // nama sql
             $sql = date('dmYHis') . '.sql';
             // unggah sql ke dir "app/storage/restores"
             Input::file('sql')->move(storage_path() . '/restores/', $sql);
             // path file
             $file = storage_path() . '/restores/' . $sql;
             // dump database
             $dump = new Dump();
             $dump->file($file)->dsn($this->dsn)->user($this->user)->pass($this->pass);
             new Import($dump);
             // hapus file restore
             unlink($file);
             // tidak ada sql
         } else {
             // pesan
             $sql = 'Sql gagal diunggah.';
             return Response::json(compact('sql'));
         }
     }
 }
开发者ID:udibagas,项目名称:digilib,代码行数:35,代码来源:DatabaseController.php

示例3: index

 public function index()
 {
     $analytics = new Analytics();
     $statusCode = 200;
     $response = ['numTweets' => $analytics->numTweets(), 'numTweetsWithLink' => $analytics->numTweetsWithLink(), 'numTweetsTypeRT' => $analytics->numTweetsTypeRT(), 'numTimesRetweeted' => $analytics->numTimesRetweeted(), 'avgNumCharacters' => $analytics->avgNumCharacters()];
     return \Response::json($response, $statusCode);
 }
开发者ID:nadlerjessie,项目名称:twitter-analysis,代码行数:7,代码来源:AnalyticsController.php

示例4: create

 /**
  * Create a Job
  * @return \Illuminate\Http\JsonResponse
  */
 public function create()
 {
     Log::info(\Input::all());
     $inputdata = \Input::all();
     $success = false;
     $inputdata["mandate_start"] = strtotime($inputdata["mandate_start"]);
     $inputdata["mandate_end"] = strtotime($inputdata["mandate_end"]);
     $inputdata["date_of_entry"] = strtotime($inputdata["date_of_entry"]);
     if ($this->validator->validate(\Input::all())) {
         $job = Job::create($inputdata);
         if (\Input::has('skills')) {
             $skills = [];
             foreach (\Input::get('skills') as $skill) {
                 $skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0];
             }
             $job->skills()->attach($skills);
         }
         if (\Input::get('agent_id')) {
             $agent = Agent::find(\Input::get('agent_id'));
             // $job->agents()->attach($agent->user_id);
             $job->agent_id = $agent->user_id;
         }
     }
     $success = $job == true;
     return \Response::json(['success' => $success]);
 }
开发者ID:nilove,项目名称:motibubackend,代码行数:30,代码来源:JobsController.php

示例5: putRequest

 /**
  * Saves user submissions for Independent Sponsor requests.
  */
 public function putRequest()
 {
     //Validate input
     $rules = array('address1' => 'required', 'city' => 'required', 'state' => 'required', 'postal_code' => 'required', 'phone' => 'required');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Response::json($this->growlMessage($validation->messages()->all(), 'error'), 400);
     }
     //Add new user information to their record
     $user = Auth::user();
     $user->address1 = Input::get('address1');
     $user->address2 = Input::get('address2');
     $user->city = Input::get('city');
     $user->state = Input::get('state');
     $user->postal_code = Input::get('postal_code');
     $user->phone = Input::get('phone');
     $user->save();
     if (!$user->getSponsorStatus()) {
         //Add UserMeta request
         $request = new UserMeta();
         $request->meta_key = UserMeta::TYPE_INDEPENDENT_SPONSOR;
         $request->meta_value = 0;
         $request->user_id = $user->id;
         $request->save();
     }
     return Response::json();
 }
开发者ID:krues8dr,项目名称:madison,代码行数:30,代码来源:SponsorApiController.php

示例6: postTerminal

 public function postTerminal()
 {
     if (\Request::ajax()) {
         $terminal_password = \Config::get('laraedit::laraedit.terminal.password');
         $command = '';
         if (!empty($_POST['command'])) {
             $command = $_POST['command'];
         }
         if (strtolower($command == 'exit')) {
             \Session::put('term_auth', false);
             $output = '[CLOSED]';
         } else {
             if (\Session::get('term_auth') !== true) {
                 if ($command == $terminal_password) {
                     \Session::put('term_auth', true);
                     $output = '[AUTHENTICATED]';
                 } else {
                     $output = 'Enter Password:';
                 }
             } else {
                 $Terminal = new TerminalController();
                 $output = '';
                 $command = explode("&&", $command);
                 foreach ($command as $c) {
                     $Terminal->command = $c;
                     $output .= $Terminal->Process();
                 }
             }
         }
         return \Response::json(htmlentities($output));
     }
 }
开发者ID:ibourgeois,项目名称:laraedit,代码行数:32,代码来源:LaraeditController.php

示例7: getVentas

 public function getVentas()
 {
     $fecha = Input::get('fecha');
     $detallescaja = Detallecaja::whereBetween('fechainicio', [$fecha . ' 00:00:00', $fecha . ' 23:59:59'])->with(['ventas', 'ventas.alquiler', 'ventas.alquiler.habitacion', 'ventas.productos', 'usuario'])->get();
     return Response::json($detallescaja);
     //return View::make('reportes.ventas', compact('detallescaja'));
 }
开发者ID:tavo7,项目名称:hotel,代码行数:7,代码来源:ReportesController.php

示例8: avatarUpload

 /**
  * 头像上传
  *
  * 这里不直接注入自定义的 Request 类, 因为直接注入的话如果上传的文件不符合规则, 直接被拦截了, 进不到这个方法, 实现不了 AJAX 提交
  * 因此在这方法里面进行验证, 再把错误用 json 返回到页面上
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function avatarUpload(Request $request)
 {
     $file = $request->file('avatar');
     $avatarRequest = new AvatarRequest();
     $validator = \Validator::make($request->only('avatar'), $avatarRequest->rules());
     if ($validator->fails()) {
         return \Response::json(['success' => false, 'errors' => $validator->messages()]);
     }
     $user = $this->authRepository->user();
     $destination = 'avatar/' . $user->username . '/';
     // 文件最终存放目录
     file_exists($destination) ? '' : mkdir($destination, 0777);
     $clientName = $file->getClientOriginalName();
     // 原文件名
     $extension = $file->getClientOriginalExtension();
     // 文件扩展名
     $newName = md5(date('ymd') . $clientName) . '.' . $extension;
     $avatarPath = '/' . $destination . $newName;
     $oldAvatar = substr($user->avatar, 1);
     // 旧头像路径, 把路径最前面的 / 删掉
     if ($file->move($destination, $newName)) {
         $this->authRepository->update(['avatar' => $avatarPath], $user->id);
         file_exists($oldAvatar) ? unlink($oldAvatar) : '';
         return \Response::json(['success' => true, 'avatar' => $avatarPath]);
     }
 }
开发者ID:axex,项目名称:kratos,代码行数:36,代码来源:AdminMeController.php

示例9: postFacturas

 public function postFacturas()
 {
     date_default_timezone_set('America/Caracas');
     //comprobamos si es una petición ajax
     if (Request::ajax()) {
         //validamos el formulario
         $registerData = array('factura' => Input::get('factura'), 'fecha_fac' => Input::get('fecha_fac'), 'n_factura' => Input::get('n_factura'), 'n_control' => Input::get('n_control'), 'n_nota_debito' => Input::get('n_nota_debito'), 'n_nota_credito' => Input::get('n_nota_credito'), 'tipo_transa' => Input::get('tipo_transa'), 'n_fact_ajustada' => Input::get('n_fact_ajustada'), 'total_compra' => Input::get('total_compra'), 'exento' => Input::get('exento'), 'base_imp' => Input::get('base_imp'), 'iva' => Input::get('iva'), 'impuesto_iva' => Input::get('impuesto_iva'), 'iva_retenido' => Input::get('iva_retenido'), 'id_proveedor' => Input::get('id_proveedor'), 'id_user' => Input::get('id_user'), 'update_user' => Input::get('update_user'), 'id_reporte' => Input::get('id_reporte'));
         $rules = array('factura' => 'unique:facturas', 'fecha_fac' => 'required', 'n_factura' => '', 'n_control' => 'required', 'n_nota_debito' => '', 'n_nota_credito' => '', 'tipo_transa' => 'required', 'n_fact_ajustada' => '', 'total_compra' => 'required|numeric', 'exento' => 'numeric', 'base_imp' => 'numeric', 'iva' => '', 'impuesto_iva' => 'numeric', 'iva_retenido' => 'numeric', 'id_user' => '', 'update_user' => '', 'id_reporte' => '');
         $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'unique' => 'La factura ingresada ya está agregada en la base de datos.', 'confirmed' => 'Los passwords no coinciden.');
         $validation = Validator::make(Input::all(), $rules, $messages);
         //si la validación falla redirigimos al formulario de registro con los errores
         if ($validation->fails()) {
             //como ha fallado el formulario, devolvemos los datos en formato json
             //esta es la forma de hacerlo en laravel, o una de ellas
             return Response::json(array('success' => false, 'errors' => $validation->getMessageBag()->toArray()));
             //en otro caso ingresamos al usuario en la tabla usuarios
         } else {
             //creamos un nuevo usuario con los datos del formulario
             $content = new Factura($registerData);
             $content->save();
             //si se realiza correctamente la inserción envíamos un mensaje
             //conforme se ha registrado correctamente
             if ($content) {
                 $facturas = DB::table('facturas')->get();
                 return Response::json(array('success' => true, 'message' => "<h3></h3>", 'facturas' => $facturas));
             }
         }
     }
 }
开发者ID:joserph,项目名称:app-retenciones,代码行数:29,代码来源:FacturasController.php

示例10: upload

 public function upload()
 {
     $file = Input::file('file');
     $input = array('image' => $file);
     $rules = array('image' => 'image');
     $validator = Validator::make($input, $rules);
     $imagePath = 'public/uploads/';
     $thumbPath = 'public/uploads/thumbs/';
     $origFilename = $file->getClientOriginalName();
     $extension = $file->getClientOriginalExtension();
     $mimetype = $file->getMimeType();
     if (!in_array($extension, $this->whitelist)) {
         return Response::json('Supported extensions: jpg, jpeg, gif, png', 400);
     }
     if (!in_array($mimetype, $this->mimeWhitelist) || $validator->fails()) {
         return Response::json('Error: this is not an image', 400);
     }
     $filename = str_random(12) . '.' . $extension;
     $image = ImageKit::make($file);
     //save the original sized image for displaying when clicked on
     $image->save($imagePath . $filename);
     // make the thumbnail for displaying on the page
     $image->fit(640, 480)->save($thumbPath . 'thumb-' . $filename);
     if ($image) {
         $dbimage = new Image();
         $dbimage->thumbnail = 'uploads/thumbs/thumb-' . $filename;
         $dbimage->image = 'uploads/' . $filename;
         $dbimage->original_filename = $origFilename;
         $dbimage->save();
         return $dbimage;
     } else {
         return Response::json('error', 400);
     }
 }
开发者ID:bobseven,项目名称:onimage-site,代码行数:34,代码来源:ImageController.php

示例11: postFoodAreaStore

 public function postFoodAreaStore()
 {
     $post = Input::all();
     $response = array();
     $model = App::make("Category");
     switch ($post["action"]) {
         case "create":
             $data = $post["data"];
             $data["parent_code"] = "FOOD_AREA";
             $data["level"] = "2";
             $response = $this->saveModel($data, $model, Category::$rules, Category::$validatorMessages);
             break;
         case "edit":
             $data = $post["data"];
             $data["parent_code"] = "FOOD_AREA";
             $data["level"] = "2";
             $model = $model->find($post["id"]);
             $response = $this->saveModel($data, $model, Category::$rules, Category::$validatorMessages);
             break;
         case "remove":
             $ids = $post["id"];
             foreach ($ids as $id) {
                 $data = $model->find($id);
                 $data->delete();
             }
             break;
     }
     return Response::json($response);
 }
开发者ID:Kangaroos,项目名称:oneshike,代码行数:29,代码来源:FoodController.php

示例12: termsAjaxHandler

 protected function termsAjaxHandler()
 {
     \Plugin::add_action('ajax_backend_get_taxonomy_terms', function () {
         $terms = $this->app->make(Repositories\TermTaxonomyRepository::class)->ajaxGetSelect2TaxonomyTerms(\Request::get('taxonomy'), \Request::get('term'), \Request::get('value'));
         return \Response::json($terms)->send();
     }, 0);
     \Plugin::add_action('ajax_backend_add_taxonomy_term', function () {
         $term = \Request::all();
         $response = [];
         if (count($term) > 1) {
             $termKeys = array_keys($term);
             $termValues = array_values($term);
             $taxName = str_replace('new', '', $termKeys[0]);
             $taxObj = $this->app->make('Taxonomy')->getTaxonomy($taxName);
             $termName = $termValues[0];
             $termParent = 0 != $termValues[1] ? (int) $termValues[1] : null;
             $postId = isset($termValues[2]) ? $termValues[2] : 0;
             $createdTerm = $this->app->make('Taxonomy')->createTerm($termName, $taxName, ['parent' => $termParent]);
             if ($createdTerm && !$createdTerm instanceof EtherError) {
                 $result['replaces'][$taxName . '_parent_select'] = View::make('backend::post.taxonomy-parent-select', ['taxName' => $taxName, 'taxObj' => $taxObj])->render();
                 $result['replaces'][$taxName . '_checklist'] = View::make('backend::post.taxonomy-checklist', ['taxName' => $taxName, 'postId' => $postId, 'taxObj' => $taxObj])->render();
                 $response['success'] = $result;
             } else {
                 $response['error'] = $response['error'] = $createdTerm->first();
             }
         } else {
             $response['error'] = 'Invalid Arguments Supplied';
         }
         return \Response::json($response)->send();
     }, 0);
 }
开发者ID:puresolcom,项目名称:polyether,代码行数:31,代码来源:TaxonomyServiceProvider.php

示例13: postVerify

 public function postVerify()
 {
     $this->beforeFilter('admin');
     $request = Input::get('request');
     $status = Input::get('status');
     if (!Group::isValidStatus($status)) {
         throw new \Exception("Invalid value for verify request");
     }
     $group = Group::where('id', '=', $request['id'])->first();
     if (!$group) {
         throw new \Exception("Invalid Group");
     }
     $group->status = $status;
     DB::transaction(function () use($group) {
         $group->save();
         switch ($group->status) {
             case Group::STATUS_ACTIVE:
                 $group->createRbacRules();
                 break;
             case Group::STATUS_PENDING:
                 $group->destroyRbacRules();
                 break;
         }
     });
     return Response::json($group);
 }
开发者ID:krues8dr,项目名称:madison,代码行数:26,代码来源:GroupsApiController.php

示例14: postDelete

 /**
  * Remove the specified company from storage.
  *
  * @param $company
  * @return Response
  */
 public function postDelete($model)
 {
     // Declare the rules for the form validation
     $rules = array('id' => 'required|integer');
     // Validate the inputs
     $validator = Validator::make(Input::All(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $id = $model->id;
         $model->delete();
         $file_path = public_path() . '/uploads/' . $model->filename;
         $file_ok = true;
         if (File::exists($file_path)) {
             $file_ok = false;
             File::delete($file_path);
             if (!File::exists($file_path)) {
                 $file_ok = true;
             }
         }
         // Was the blog post deleted?
         $Model = $this->modelName;
         $model = $Model::find($id);
         if (empty($model) && $file_ok) {
             // Redirect to the blog posts management page
             return Response::json(['success' => 'success', 'reload' => true]);
         }
     }
     // There was a problem deleting the blog post
     return Response::json(['error' => 'error', 'reload' => false]);
 }
开发者ID:strikles,项目名称:php,代码行数:36,代码来源:PicturesController.php

示例15: postEditar

 public function postEditar()
 {
     if (Request::ajax()) {
         $usurioid = Input::get('id');
         $tipopersona = Input::get('tipo_persona');
         $usuario['usuario_updated_at'] = Auth::user()->id;
         $usuario = Usuario::find(Auth::user()->id);
         $perfilId = $usuario['perfil_id'];
         $data2 = array(Auth::user()->id, $usurioid, $tipopersona);
         $desactivardata = PermisoEventos::getDesactivarpermisos($data2);
         $metodo = Input::get('metodo');
         for ($i = 0; $i < count($metodo); $i++) {
             $metodoId = $metodo[$i];
             $data = array($metodoId, $usurioid, $tipopersona, '2', $usuario['usuario_updated_at'], $usuario['usuario_updated_at']);
             $datos = PermisoEventos::getAgregarEvento($data);
         }
         $consulta = Input::get('consulta');
         for ($i = 0; $i < count($consulta); $i++) {
             $consultaId = $consulta[$i];
             $data = array($consultaId, $usurioid, $tipopersona, '1', $usuario['usuario_updated_at'], $usuario['usuario_updated_at']);
             $datos = PermisoEventos::getAgregarEvento($data);
         }
         return Response::json(array('rst' => 1, 'msj' => "Se modifico permisos exitosamente"));
     }
 }
开发者ID:lcalderonc,项目名称:hdc2016,代码行数:25,代码来源:PermisoEventosController.php


注:本文中的Response::json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。