本文整理汇总了PHP中Illuminate\Support\Facades\Request::ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::ajax方法的具体用法?PHP Request::ajax怎么用?PHP Request::ajax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::ajax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: item
/**
* Gets the item edit page / information
*
* @param string $modelName
* @param mixed $itemId
*/
public function item($modelName, $itemId = 0)
{
$config = App::make('itemconfig');
$fieldFactory = App::make('admin_field_factory');
$actionFactory = App::make('admin_action_factory');
$columnFactory = App::make('admin_column_factory');
$actionPermissions = $actionFactory->getActionPermissions();
$fields = $fieldFactory->getEditFields();
//if it's ajax, we just return the item information as json
if (Request::ajax())
{
//try to get the object
$model = $config->getModel($itemId, $fields, $columnFactory->getIncludedColumns($fields));
if ($model->exists)
{
$model = $config->updateModel($model, $fieldFactory, $actionFactory);
}
return $actionPermissions['view'] ? $model->toJson() : Response::json(array(
'success' => false,
'errors' => "You do not have permission to view this item",
));
}
else
{
$view = View::make("administrator::index", array(
'itemId' => $itemId,
));
//set the layout content and title
$this->layout->content = $view;
}
}
示例2: __construct
function __construct()
{
//
self::$settings = Config::get('garbarinoviajes');
//
self::$static = url('statics') . '/';
//
if (false == \Illuminate\Support\Facades\Request::ajax()) {
self::addJsHeader('http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js');
self::addCss('main.css');
// ex bootstrap
self::addCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
self::addCss('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.css');
self::addCss('details.css');
// self::addCss('1200.css');
self::addJsFooter('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
self::addJsFooter('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js');
}
//
\Illuminate\Support\Facades\Blade::extend(function ($value) {
return preg_replace('/(\\s*)@(break|continue)(\\s*)/', '$1<?php $2; ?>$3', $value);
});
//
view()->composer('*', 'App\\Http\\Composers\\ViewComposer');
}
示例3: item
/**
* Gets the item edit page / information
*
* @param string $modelName
* @param mixed $itemId
*/
public function item($modelName, $itemId = 0)
{
$config = App::make('itemconfig');
$fieldFactory = App::make('admin_field_factory');
$actionFactory = App::make('admin_action_factory');
$columnFactory = App::make('admin_column_factory');
$actionPermissions = $actionFactory->getActionPermissions();
$fields = $fieldFactory->getEditFields();
//if it's ajax, we just return the item information as json
if (Request::ajax()) {
//try to get the object
$model = $config->getModel($itemId, $fields, $columnFactory->getIncludedColumns($fields));
if ($model->exists) {
$model = $config->updateModel($model, $fieldFactory, $actionFactory);
}
//!!!!!!!!!!!!Response::json()后的值不会包含$model的隐藏属性,所以为了hidden变量也能进行编辑,必须先让隐藏属性变成不隐藏的. edit by: linuxsong
$model->setHidden(array());
$response = $actionPermissions['view'] ? Response::json($model) : Response::json(array('success' => false, 'errors' => "You do not have permission to view this item"));
//set the Vary : Accept header to avoid the browser caching the json response
return $response->header('Vary', 'Accept');
} else {
$view = View::make("administrator::index", array('itemId' => $itemId));
//set the layout content and title
$this->layout->content = $view;
}
}
示例4:
function request_online_order()
{
if (Request::ajax()) {
$data = Input::all();
\App\Restaurants::where('id', '=', $data['id'])->increment('request_order');
}
}
示例5: runCrawler
public function runCrawler()
{
switch (Input::get('action')) {
case 'recreateurls':
foreach (Page::all() as $page) {
$page->url = Page::getUrl($page->id);
$page->save();
}
die("Recreated URL:s");
break;
case 'crawl':
Crawler::url(Input::get('crawl_url'), Input::get('crawl_found_links') ? true : false);
if (Input::get('crawl_convert')) {
Crawler::createPages();
}
break;
case 'convertToPages':
Crawler::convertToPages();
break;
default:
return Response::json('Invalid action', 400);
break;
}
if (Request::ajax()) {
return Response::json(Lang::get('cms::m.crawler-done'), 200);
} else {
return Redirect::route('crawler')->with('flash_notice', Lang::get('cms::m.crawler-done'));
}
}
示例6: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->filter('auth', function () {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
} else {
return Redirect::guest('/');
}
}
});
$router->filter('auth.basic', function () {
return Auth::basic();
});
$router->filter('guest', function () {
if (Auth::check()) {
return Redirect::to('/');
}
});
$router->filter('admin', function () {
if (Auth::check()) {
if (Auth::user()->email != "ceesco53@gmail.com") {
return Redirect::to('/');
}
} else {
return Redirect::to('/');
}
});
parent::boot($router);
}
示例7: error
/**
* Response with error message.
* @param $message
* @return $this|static
*/
protected function error($message)
{
if (Request::ajax()) {
return CMSResponse::failed([$message]);
}
return view('cms::app', compact('user'))->withErrors([$message]);
}
示例8: show
/**
* Show place.
*
* @return \Illuminate\View\View
*/
public function show($slug)
{
$model = $this->repository->bySlug($slug);
if (Request::ajax()) {
return $model;
}
return view('places::public.show')->with(compact('model'));
}
示例9: showUsers
public function showUsers()
{
$users = Sentry::findAllUsers();
if (Request::ajax()) {
return View::make('admin::users.user_list_center', compact('users'));
}
return View::make('admin::users.users_list', compact('users'));
}
示例10: index
public function index()
{
if (Request::ajax()) {
return view('ajax.ajaxAboutNew');
} else {
return view('about');
}
}
示例11: response
/**
* Returns a suitable response from the type of request.
*
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*/
public function response()
{
if (Request::ajax()) {
return Response::json(['message' => $this->message, 'messageType' => $this->messageType, 'redirect' => $this->redirect]);
} else {
return Redirect::to($this->redirect)->with('message', $this->message)->with('messageType', $this->messageType);
}
}
示例12: search
/**
* Search action
* @param $username
*
* @return mixed
*/
public function search()
{
$username = Input::get('name');
$foundUsers = DB::table('users')->where('name', 'like', "%{$username}%")->select(['id', 'name', 'email'])->get();
if (Request::ajax()) {
return Response::json(['users' => $foundUsers, 'total_count' => count($foundUsers)]);
}
}
示例13: index
public function index()
{
$articles = Article::paginate(20);
if (Request::ajax()) {
return \Response::json(view("blog", compact("articles"))->render());
}
return view("blog", compact("articles"));
}
示例14: postStatus
public function postStatus(StatusRequest $request)
{
if (Request::ajax()) {
$user = Auth::user();
$status = Input::get('status');
$this->status->postStatus($user);
return $status;
}
}
示例15: getDone
public function getDone($id)
{
if (Request::ajax()) {
$task = Todo::find($id);
$task->status = 1;
$task->save();
return "OK";
}
}