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


PHP Response::json方法代码示例

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


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

示例1: postValidate

 public function postValidate()
 {
     $validator = $this->validator->make($this->input->all(), array('recaptcha_response_field' => 'required|recaptcha'));
     if ($validator->fails()) {
         return $this->response->json(array('result' => 'failed'));
     }
     $this->session->put('captcha.passed.time', $this->mockably->microtime());
     return $this->response->json(array('result' => 'success'));
 }
开发者ID:LaraGit,项目名称:larapress,代码行数:9,代码来源:CaptchaController.php

示例2: updateversion

 /**
  * Tracker update application
  *
  * 1. Check input
  * 2. Check auth
  * 3. Set current absence 
  * @return Response
  */
 function updateversion()
 {
     $attributes = Input::only('application');
     //1. Check input
     if (!$attributes['application']) {
         return Response::json('101', 200);
     }
     if (!isset($attributes['application']['api']['client']) || !isset($attributes['application']['api']['secret']) || !isset($attributes['application']['api']['tr_ver']) || !isset($attributes['application']['api']['station_id']) || !isset($attributes['application']['api']['email']) || !isset($attributes['application']['api']['password'])) {
         return Response::json('102', 200);
     }
     //2. Check auth
     $client = \App\Models\Api::client($attributes['application']['api']['client'])->secret($attributes['application']['api']['secret'])->workstationaddress($attributes['application']['api']['station_id'])->with(['branch'])->first();
     if (!$client) {
         $filename = storage_path() . '/logs/appid.log';
         $fh = fopen($filename, 'a+');
         $template = date('Y-m-d H:i:s : Login : ') . json_encode($attributes['application']['api']) . "\n";
         fwrite($fh, $template);
         fclose($fh);
         return Response::json('402', 200);
     }
     //3. Set current absence
     if ((double) $attributes['application']['api']['tr_ver'] < (double) Config::get('current.absence.version')) {
         return Response::json('sukses|' . Config::get('current.absence.url1') . '|' . Config::get('current.absence.url2'), 200);
     }
     return Response::json('200', 200);
 }
开发者ID:ThunderID,项目名称:HRIS-API,代码行数:34,代码来源:UpdateController.php

示例3: postSkin

 /**
  * Change skin.
  *
  * @param Request $request
  */
 public function postSkin(Request $request)
 {
     $skin = $request->get('value', 'default-skin');
     if (Config::where('key', 'skin')->update(['value' => $skin])) {
         return Response::json(['status' => 1]);
     }
 }
开发者ID:Germey,项目名称:GermyGallery,代码行数:12,代码来源:ConfigController.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     try {
         $statusCode = 200;
         $response = ['Mecanex_Users' => []];
         $mecanexusers = MecanexUser::all();
         foreach ($mecanexusers as $mecanexuser) {
             $response['Mecanex_Users'][] = $mecanexuser;
             //					[
             //					'email' => $mecanexuser->email,
             //					'name' => $mecanexuser->name,
             //					'surname' => $mecanexuser->surname,
             //					'gender' => $mecanexuser->gender_id,
             //					'age' => $mecanexuser->age_id,
             //					'education' => $mecanexuser->education_id,
             //					'occupation' => $mecanexuser->occupation_id,
             //					'country' => $mecanexuser->country_id,
             //										];
         }
     } catch (Exception $e) {
         $statusCode = 400;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
开发者ID:skafetzo,项目名称:SPtool,代码行数:30,代码来源:MecanexUserApiController.php

示例5: postCrop

 public function postCrop()
 {
     $form_data = Input::all();
     $image_url = $form_data['imgUrl'];
     // resized sizes
     $imgW = $form_data['imgW'];
     $imgH = $form_data['imgH'];
     // offsets
     $imgY1 = $form_data['imgY1'];
     $imgX1 = $form_data['imgX1'];
     // crop box
     $cropW = $form_data['width'];
     $cropH = $form_data['height'];
     // rotation angle
     $angle = $form_data['rotation'];
     $filename_array = explode('/', $image_url);
     $filename = $filename_array[sizeof($filename_array) - 1];
     $manager = new ImageManager();
     $image = $manager->make($image_url);
     $image->resize($imgW, $imgH)->rotate(-$angle)->crop($cropW, $cropH, $imgX1, $imgY1)->save(env('UPLOAD_PATH') . 'cropped-' . $filename);
     if (!$image) {
         return Response::json(['status' => 'error', 'message' => 'Server error while uploading'], 200);
     }
     return Response::json(['status' => 'success', 'url' => env('URL') . 'uploads/cropped-' . $filename], 200);
 }
开发者ID:codingo-me,项目名称:laravel-croppic,代码行数:25,代码来源:CropController.php

示例6: destroy

 public function destroy()
 {
     $conferenceId = Input::get('conferenceId');
     $talkRevisionId = Input::get('talkRevisionId');
     $this->dispatch(new DestroySubmission($conferenceId, $talkRevisionId));
     return Response::json(['status' => 'success', 'message' => 'Talk Un-Submitted']);
 }
开发者ID:elazar,项目名称:symposium,代码行数:7,代码来源:SubmissionsController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($this->request->all(), ['title' => 'required|min:5', 'address' => 'required', 'description' => 'required|min:5', 'price' => 'required', 'available' => 'required']);
     if ($validator->fails()) {
         return json_encode(['message', 'Validation Fails']);
     } else {
         if ($this->request->input('amenities')) {
             $amenities = implode(',', $this->request->input('amenities'));
         } else {
             $amenities = "none";
         }
         if ($this->request->input('pets')) {
             $pets = implode(',', $this->request->input('pets'));
         } else {
             $pets = 'none';
         }
         // will use try and catch later
         $this->request->merge(['amenities' => $amenities]);
         $this->request->merge(['pets' => $pets]);
         if ($this->request->hasFile('file')) {
             $file_name = str_random(30);
             $file_extenson = $this->request->file('file')->getClientOriginalExtension();
             $newFilename = $file_name . '.' . $file_extenson;
             $this->request->file('file')->move(public_path() . '/images/properties/covers/', $newFilename);
             $this->request->merge(['cover' => $newFilename]);
         }
         $this->property->create($this->request->all());
         return Response::json(['status' => 200, 'message' => 'Saved']);
     }
 }
开发者ID:omusico,项目名称:rentity,代码行数:35,代码来源:ListingController.php

示例8: google

 /**
  *
  * @param Request $request
  *
  * @return mixed
  */
 public function google(Request $request)
 {
     if ($request->has('redirectUri')) {
         config()->set("services.google.redirect", $request->get('redirectUri'));
     }
     $provider = Socialite::driver('google');
     $provider->stateless();
     $profile = $provider->user();
     $email = $profile->email;
     $name = $profile->name;
     $google_token = $profile->token;
     $google_id = $profile->id;
     $user = User::where('email', $email)->first();
     if (is_null($user)) {
         $data = ['email' => $email, 'name' => $name, 'password' => null, 'confirmation_code' => null, 'confirmed' => '1', 'social_auth_provider_access_token' => $google_token, 'google_id' => $google_id, 'social_auth_provider' => 'google', 'social_auth_provider_id' => $google_id];
         $user = User::create($data);
         $response = Response::json($user);
         return $response;
     } else {
         $user->google_id = $google_id;
         $user->social_auth_provider_access_token = $profile->token;
         $user->social_auth_provider_id = $profile->id;
         $user->social_auth_provider = 'google';
         $user->save();
         $response = Response::json($user);
         return $response;
     }
 }
开发者ID:Scaledesk,项目名称:gritwings,代码行数:34,代码来源:AuthController.php

示例9: store

 /**
  * Upload attachment to storage
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (!Session::has('questions_hash')) {
         Session::put('questions_hash', md5(time()));
     }
     return Response::json(['attachment' => \QuestionsService::uploadAttachment($request->file('upl'))]);
 }
开发者ID:lyovkin,项目名称:v2board,代码行数:12,代码来源:QuestionsController.php

示例10: createAndStartNewStream

 public function createAndStartNewStream($arrData)
 {
     $stream = $this->stream->first();
     $stream->update($arrData);
     event(new StreamEvent($stream->streaming));
     return Response::json(['success' => true, 'isStreaming' => $stream->streaming]);
 }
开发者ID:BarDav,项目名称:stream,代码行数:7,代码来源:StreamRepository.php

示例11: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         return Response::json(['error' => ['message' => 'Resource not found']], 404);
     }
     return parent::render($request, $e);
 }
开发者ID:BinaryStudioAcademy,项目名称:reviewr,代码行数:14,代码来源:Handler.php

示例12: catalogo

 public function catalogo()
 {
     $cliente_id = User::where('email', Input::get('email'))->get()[0]->load('miembrosDe')['miembrosDe'][0]->cliente_id;
     $catalogo = Catalogos::find(Input::get('catalogo_id'))->load('menu')['menu'];
     $catalogo = $this->preparoCatalogo($catalogo);
     return Response::json($catalogo);
 }
开发者ID:yarrib76,项目名称:catalogo,代码行数:7,代码来源:EnviarCatalogoController.php

示例13: doDelelePhrase

 public function doDelelePhrase()
 {
     $id_record = Input::get("id");
     Trans::find($id_record)->delete();
     Trans::reCacheTrans();
     return Response::json(array('status' => 'ok'));
 }
开发者ID:arturishe21,项目名称:translations,代码行数:7,代码来源:TranslateController.php

示例14: login

 /**
  * POST /api/login
  */
 public function login()
 {
     // Get all data send in post
     $loginFormData = Request::all();
     // Create rules for the validator
     $validator = Validator::make($loginFormData, ['user_email' => 'required|email', 'user_password' => 'required']);
     // If validator fails return a 404 response
     if ($validator->fails()) {
         return Response::json(['status_code' => 404, 'errors' => $validator->errors()->all()], 404);
     }
     $user = User::where('email', '=', strtolower($loginFormData['user_email']))->first();
     if (!$user) {
         return Response::json(['status_code' => 404, 'errors' => ['Votre compte est introuvable dans notre base de donnée.']], 404);
     } else {
         if ($user->activated == 0) {
             return Response::json(['status_code' => 404, 'errors' => ["Merci d'activer votre compte."]], 404);
         } else {
             if (!Hash::check($loginFormData['user_password'], $user->password)) {
                 return Response::json(['status_code' => 404, 'errors' => ["Votre mot de passe est incorrect."]], 404);
             }
         }
     }
     $room = Room::find($user->room_id);
     $partner = User::find($user->is_partner ? $room->user_id : $room->partner_id);
     if ($partner->activated == 0) {
         return Response::json(['status_code' => 404, 'errors' => ["Le compte de votre partenaire n'a pas été activé."]], 404);
     }
     // Success
     return Response::json(['status_code' => 200, 'success' => "Login success", 'data' => ['me' => $user, 'partner' => $partner, 'room' => $room]]);
 }
开发者ID:Mathew78540,项目名称:both,代码行数:33,代码来源:AuthController.php

示例15: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, RentalUnit $rentalUnit)
 {
     //Use fill() to automatically fill in the fields
     $rentalUnit->fill(Input::all());
     $rentalUnit->save();
     return Response::json($rentalUnit);
 }
开发者ID:VJan-fin,项目名称:Roomie,代码行数:14,代码来源:RentalUnitController.php


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