本文整理汇总了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');*/
}
示例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'));
}
示例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);
}
示例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()));
}
}
示例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'));
}
示例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);
}
示例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));
}
示例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';
});
示例9: getBugDetails
public function getBugDetails($id)
{
$bug = $this->bug->find($id);
return Response::JSON($bug);
}
示例10: getGroupList
public function getGroupList()
{
$data = array('status' => true);
$data['list'] = $this->todoGroup->getlist();
return Response::JSON($data);
}
示例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));
}
示例12: deleteTodo
public function deleteTodo($todoId)
{
if ($this->todo->destroy($todoId)) {
return Response::JSON(array('status' => 'success'));
} else {
return Response::JSON(array('status' => 'fail'));
}
}