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


PHP Response::JSON方法代码示例

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


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

示例1: contact

 public function contact()
 {
     $validation = Validator::make(array('name' => Input::get('name'), 'phone' => Input::get('phone'), 'email' => Input::get('email'), 'sucursal' => Input::get('sucursal'), 'mensaje' => Input::get('mensaje')), array('name' => array('required'), 'phone' => array('required'), 'email' => array('required', 'email'), 'sucursal' => array('required'), 'mensaje' => array('required')));
     if ($validation->fails()) {
         if (\Request::ajax()) {
             $messages = $validation->messages();
             return \Response::JSON(array('messages' => $messages), 400);
         }
         return \Redirect::to(\Input::get('from'))->withInput()->withErrors($validation);
     }
     $data = array('name' => Input::get('name'), 'phone' => Input::get('phone'), 'email' => Input::get('email'), 'sucursal' => Input::get('sucursal'), 'mensaje' => Input::get('enquiry'));
     /*  $to = "mario@maniak.com.mx";
             $subject = "My subject";
             $headers = "From: webmaster@example.com" . "\r\n" .
                 "CC: somebodyelse@example.com";
     
             mail($to, $subject, $data, $headers);*/
     Mail::send('emails.contacto', $data, function ($message) use($data) {
         $message->to('mario@maniak.com.mx')->from($data['name'])->subject('Welcome!');
     });
     return 'El Mensaje ha sido enviado, muchas gracias por enviarnos tus sugerencias!';
     /* $this->contactForm->validate(Input::all());
     
             $data = array( 'email' => 'mario@maniak.com.mx', 'name' => 'Lar', 'from' => 'sample@sample.comt', 'phone' => 'Vel', 'sucursal' => 'Vel', 'mensaje' => 'Vel' );
     
             Mail::send( 'emails.contacto', $data, function( $message ) use ($data)
             {
                 $message->to( $data['email'] )->from( $data['from'])->subject( 'Welcome!' );
             });
     
             return Redirect::back()->withInput();
     //       return Input::get('name').Input::get('phone');*/
 }
开发者ID:mariotr83,项目名称:sushiito,代码行数:33,代码来源:HomeController.php

示例2: apply

 public function apply()
 {
     if (\Config::get('laravel-jobs::apply') == false) {
         \App::abort(404);
     }
     $rules = array('name' => 'required', 'email' => 'required|email', 'cv' => 'mimes:' . \Config::get('laravel-jobs::cv_allowed_mimes'));
     $validator = \Validator::make(\Input::all(), $rules, \Lang::get('laravel-jobs::copy.validation'));
     $validator->sometimes('cv', 'required', function ($input) {
         return \Config::get('laravel-jobs::is_cv_required');
     });
     $validator->sometimes('letter', 'required', function ($input) {
         return \Config::get('laravel-jobs::is_covering_letter_required');
     });
     if ($validator->fails()) {
         if (\Request::ajax()) {
             $messages = $validator->messages();
             return \Response::JSON(array('messages' => $messages), 400);
         }
         return \Redirect::to(\Input::get('from'))->withInput()->withErrors($validator);
     }
     \Mail::send(\Config::get('laravel-jobs::mail.views'), \Input::all(), function ($message) {
         $message->to(\Config::get('laravel-jobs::mail.to.email'), \Config::get('laravel-jobs::mail.to.name'))->subject(\Config::get('laravel-jobs::mail.subject'));
         if (\Input::hasFile('cv')) {
             $message->attach(\Input::file('cv')->getRealPath(), array('as' => \Input::file('cv')->getClientOriginalName(), 'mime' => \Input::file('cv')->getMimeType()));
         }
     });
     return \Redirect::to(\Input::get('from'))->with('thanks_message', \Lang::get('laravel-jobs::copy.misc.sent_message'));
 }
开发者ID:yudancuk,项目名称:Laravel-Jobs,代码行数:28,代码来源:JobsController.php

示例3: delete

 public function delete()
 {
     $rules = array('newsletter_unsubscribe_email' => 'required|max:250|email|exists:fbf_newsletter_signups,email');
     $validator = \Validator::make(\Input::all(), $rules, \Lang::get('laravel-newsletter-signup::copy.unsubscribe.validation'));
     if ($validator->fails()) {
         if (\Request::ajax()) {
             $messages = $validator->messages();
             $message = $messages->first('newsletter_unsubscribe_email');
             return \Response::JSON(array('message' => $message), 400);
         }
         return \Redirect::to(\Input::get('from'))->withInput()->withErrors($validator);
     }
     $signup = Signup::withTrashed()->where('email', '=', \Input::get('newsletter_unsubscribe_email'))->first();
     if ($signup->trashed()) {
         if (\Request::ajax()) {
             return \Response::JSON(array('message' => \Lang::get('laravel-newsletter-signup::copy.unsubscribe.already_unsubscribed')), 400);
         }
         $message = new MessageBag();
         $message->add('newsletter_unsubscribe_email', \Lang::get('laravel-newsletter-signup::copy.unsubscribe.already_unsubscribed'));
         return \Redirect::to(\Input::get('from'))->withInput()->with('errors', $message);
     }
     $signup->delete();
     $success = \Lang::get('laravel-newsletter-signup::copy.unsubscribe.success');
     if (\Request::ajax()) {
         return \Response::JSON(array('message' => $success));
     }
     return \Redirect::to(\Input::get('from'))->with('newsletter_unsubscribe_email_message', $success);
 }
开发者ID:XDocker,项目名称:app,代码行数:28,代码来源:SignupsController.php

示例4: endpoint

 function endpoint()
 {
     $url = Input::get('url');
     Log::info('Endpoint hit for: ' . $url);
     if (empty($url)) {
         throw new Exception("URL is empty!");
     }
     try {
         return $this->getResultsCache($url);
     } catch (\Exception $e) {
         \Log::info($e);
         return \Response::JSON(array('error' => true, 'message' => $e->getMessage()));
     }
 }
开发者ID:webprofits,项目名称:cro-pagespeed,代码行数:14,代码来源:PageSpeedAPIController.php

示例5: send

 public function send()
 {
     $rules = \Config::get('laravel-contact-form::rules');
     $validator = \Validator::make(\Input::all(), $rules, \Lang::get('laravel-contact-form::copy.validation'));
     if ($validator->fails()) {
         if (\Request::ajax()) {
             $messages = $validator->messages();
             return \Response::JSON(array('messages' => $messages), 400);
         }
         return \Redirect::to(\Input::get('from'))->withInput()->withErrors($validator);
     }
     \Mail::send(\Config::get('laravel-contact-form::mail.views'), \Input::all(), function ($message) {
         $message->to(\Config::get('laravel-contact-form::mail.to.email'), \Config::get('laravel-contact-form::mail.to.name'))->subject(\Config::get('laravel-contact-form::mail.subject'));
     });
     return \Redirect::to(\Input::get('from'))->with('contact_form_message', \Lang::get('laravel-contact-form::copy.sent_message'));
 }
开发者ID:ck-developer,项目名称:Laravel-Contact-Form,代码行数:16,代码来源:ContactController.php

示例6: getProjectUsers

 public function getProjectUsers($projectId)
 {
     $users = $this->project->find($projectId)->users()->get(array('users.id', 'first_name', 'last_name'));
     $user1 = array();
     foreach ($users as $user) {
         array_push($user1, array('id' => $user['id'], 'name' => $user['first_name'] . " " . $user['last_name']));
     }
     return Response::JSON($user1);
 }
开发者ID:vik0803,项目名称:BugTrackerApp,代码行数:9,代码来源:ProjectsController.php

示例7: postEdit

 public function postEdit()
 {
     $files = Input::file('files');
     $file = $files[0];
     //print_r($file);
     //exit();
     $rstring = str_random(8);
     $destinationPath = realpath('storage/temp') . '/' . $rstring;
     $filename = $file->getClientOriginalName();
     $filemime = $file->getMimeType();
     $filesize = $file->getSize();
     $extension = $file->getClientOriginalExtension();
     //if you need extension of the file
     $filename = str_replace(Config::get('kickstart.invalidchars'), '-', $filename);
     $uploadSuccess = $file->move($destinationPath, $filename);
     $thumbnail = Image::make($destinationPath . '/' . $filename)->fit(320, 240)->save($destinationPath . '/th_' . $filename);
     $fileitems = array();
     if ($uploadSuccess) {
         $fileitems[] = array('url' => URL::to('storage/temp/' . $rstring . '/' . $filename), 'thumbnail_url' => URL::to('storage/temp/' . $rstring . '/th_' . $filename), 'temp_dir' => $destinationPath, 'name' => $filename, 'type' => $filemime, 'size' => $filesize, 'delete_url' => 'http://url.to/delete /file/', 'delete_type' => 'DELETE');
     }
     return Response::JSON(array('files' => $fileitems));
 }
开发者ID:awidarto,项目名称:jexadmin,代码行数:22,代码来源:UploadController.php

示例8: function

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('registration/company', function () {
    return Response::JSON(['test' => Session::getToken()]);
});
Route::get('/test', function () {
    $event_date = '2015-10-13';
    $task = (object) ['deadline_days_gap' => -2];
    $new_deadline = strtotime(-$task->deadline_days_gap . ' days', strtotime($event_date));
    echo date('Y-m-d', $new_deadline);
    return;
    $hotel = Hotel::find(4);
    Debugbar::info($hotel);
    $venue = Venue::find(77);
    $hospitality = $venue->hospitality;
    Debugbar::info($hospitality);
    $first_hotel = $hospitality->first_hotel_option()->associate($hotel);
    $first_hotel = $hospitality->first_hotel_option()->get();
    Debugbar::info($first_hotel);
    echo 'test';
});
开发者ID:strikles,项目名称:php,代码行数:31,代码来源:routes.php

示例9: getBugDetails

 public function getBugDetails($id)
 {
     $bug = $this->bug->find($id);
     return Response::JSON($bug);
 }
开发者ID:vik0803,项目名称:BugTrackerApp,代码行数:5,代码来源:BugsController.php

示例10: getGroupList

 public function getGroupList()
 {
     $data = array('status' => true);
     $data['list'] = $this->todoGroup->getlist();
     return Response::JSON($data);
 }
开发者ID:vik0803,项目名称:BugTrackerApp,代码行数:6,代码来源:TodoGroupsController.php

示例11: action_rows_per_page

 /**
  * The POST method for setting a user's rows per page
  *
  * @param ModelConfig	$config
  *
  * @return JSON
  */
 public function action_rows_per_page($config)
 {
     //get the inputted rows and the model rows
     $rows = (int) Input::get('rows', 20);
     $config->setRowsPerPage($rows);
     return Response::JSON(array('success' => true));
 }
开发者ID:SerdarSanri,项目名称:admin,代码行数:14,代码来源:admin.php

示例12: deleteTodo

 public function deleteTodo($todoId)
 {
     if ($this->todo->destroy($todoId)) {
         return Response::JSON(array('status' => 'success'));
     } else {
         return Response::JSON(array('status' => 'fail'));
     }
 }
开发者ID:vik0803,项目名称:BugTrackerApp,代码行数:8,代码来源:TodosController.php


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