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


PHP Request::ajax方法代码示例

本文整理汇总了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;
		}
	}
开发者ID:pcerbino,项目名称:falcionevega,代码行数:41,代码来源:AdminController.php

示例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');
 }
开发者ID:fcolella,项目名称:docker,代码行数:25,代码来源:Controller.php

示例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;
     }
 }
开发者ID:linuxsong,项目名称:laravel-administrator,代码行数:32,代码来源:AdminController.php

示例4:

 function request_online_order()
 {
     if (Request::ajax()) {
         $data = Input::all();
         \App\Restaurants::where('id', '=', $data['id'])->increment('request_order');
     }
 }
开发者ID:RestaurantListings,项目名称:restaurant_listings,代码行数:7,代码来源:RestaurantsController.php

示例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'));
     }
 }
开发者ID:cednet,项目名称:laravel-cms-addon,代码行数:29,代码来源:CrawlerController.php

示例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);
 }
开发者ID:siparker,项目名称:ribbbon,代码行数:36,代码来源:RouteServiceProvider.php

示例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]);
 }
开发者ID:breachofmind,项目名称:birdmin,代码行数:12,代码来源:Controller.php

示例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'));
 }
开发者ID:typicms,项目名称:places,代码行数:13,代码来源:PublicController.php

示例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'));
 }
开发者ID:arturishe21,项目名称:buider,代码行数:8,代码来源:TBUsersController.php

示例10: index

 public function index()
 {
     if (Request::ajax()) {
         return view('ajax.ajaxAboutNew');
     } else {
         return view('about');
     }
 }
开发者ID:edwardpayton,项目名称:portfolio-site,代码行数:8,代码来源:AboutController.php

示例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);
     }
 }
开发者ID:stevebauman,项目名称:core-helper,代码行数:13,代码来源:Exception.php

示例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)]);
     }
 }
开发者ID:nguyenvanduocit,项目名称:Password-Manager,代码行数:14,代码来源:UserController.php

示例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"));
 }
开发者ID:bassx1,项目名称:lessons,代码行数:8,代码来源:FrontendController.php

示例14: postStatus

 public function postStatus(StatusRequest $request)
 {
     if (Request::ajax()) {
         $user = Auth::user();
         $status = Input::get('status');
         $this->status->postStatus($user);
         return $status;
     }
 }
开发者ID:mathewsandi,项目名称:Practice,代码行数:9,代码来源:StatusController.php

示例15: getDone

 public function getDone($id)
 {
     if (Request::ajax()) {
         $task = Todo::find($id);
         $task->status = 1;
         $task->save();
         return "OK";
     }
 }
开发者ID:mathewsandi,项目名称:AjaxedToDoApp,代码行数:9,代码来源:TodoController.php


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