本文整理汇总了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'));
}
示例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);
}
示例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]);
}
}
示例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);
}
}
示例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);
}
示例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']);
}
示例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']);
}
}
示例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;
}
}
示例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'))]);
}
示例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]);
}
示例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);
}
示例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);
}
示例13: doDelelePhrase
public function doDelelePhrase()
{
$id_record = Input::get("id");
Trans::find($id_record)->delete();
Trans::reCacheTrans();
return Response::json(array('status' => 'ok'));
}
示例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]]);
}
示例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);
}