本文整理汇总了PHP中Illuminate\Http\Request::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::query方法的具体用法?PHP Request::query怎么用?PHP Request::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: url
/**
* Generates a url for Sorter
*
* @param string $field
* @param null|string $path
* @param boolean $appends
* */
public function url($field, $path = null, $appends = true)
{
if ($path === null) {
$path = $this->url->current();
}
$queryString = [$this->getFieldIndex() => $field, $this->getDirectionIndex() => $this->getConditionallyDirection($field)];
$appends && ($queryString += $this->request->query());
$url = $path . '?' . http_build_query($queryString);
return $this->url->to($url);
}
示例2: getMovies
/**
* @return Response
*/
public function getMovies(Request $request)
{
$limit = intval($request->query('limit') ?: 10);
$offset = intval($request->query('offset') ?: 0);
$movies = $this->getData();
return response()->json(['total' => count($movies), 'list' => array_slice($movies, $offset, $limit)]);
}
示例3: index
public function index(urlRequest $request)
{
//query
if ($search = $request->query('q')) {
$articles = Article::search($search)->orderBy('created_at', 'desc')->simplepaginate(18);
} elseif ($search = $request->query('id')) {
//查找伪id(photo)
$search = \App\Article::where('photo', $search)->firstOrFail()->id;
$articles = DB::table('articles')->where('id', '<=', $search)->orderBy('created_at', 'desc')->simplepaginate(18);
//伪搜索结果
$search = $request->query('id');
} else {
//DB::代替Article::
$articles = DB::table('articles')->orderBy('created_at', 'desc')->simplepaginate(18);
}
//已经点赞{!!$articles->appends(Request::except('page'))->render()!!}
//$f = DB::table('votes')->whereuser_id(Auth::user()->id)->lists('votable_id');
//http://example.com/custom/url?page=N, you should pass custom/url to the setPath
$articles->setPath('articles');
//sidebar
$hotimgs = \App\Article::where('type', 'LIKE', "%jpg%")->orderBy('vote_count', 'desc')->take(10)->get();
//return $hotimgs;
$hotreplies = \App\Reply::orderBy('vote_count', 'desc')->limit(10)->get();
return view('articles.index', compact('articles', 'search', 'hotimgs', 'hotreplies'));
}
示例4: verify
protected function verify(Request $request)
{
if (!($email = $request->query('email')) or !($token = $request->query('token'))) {
return $this->returnErrorView(trans('authentication::verification.link_invalid'));
}
if (!($emailVerification = $this->emailVerificationRepository->where('email', '=', $email)->first())) {
return $this->returnErrorView(trans('authentication::verification.email_not_found', ['email' => $email]));
}
$user = $this->userRepository->where('email', '=', $email)->firstOrFail();
if ($user->isVerified()) {
return $this->returnErrorView(trans('authentication::verification.already_verified'));
}
if ($emailVerification->attempts >= EmailVerification::MAX_ATTEMPTS) {
return $this->returnBlockedView();
}
if ($token !== $emailVerification->token) {
$emailVerification->increment('attempts');
return $this->returnErrorView(trans('authentication::verification.attempt_failed', ['time' => $emailVerification->attempts]));
}
if ($emailVerification->created_at->diffInHours(Carbon::now()) >= EmailVerification::TIMEOUT_HOURS) {
return $this->returnErrorView(trans('authentication::verification.link_expired'));
}
$this->userRepository->save($user->verify());
$this->emailVerificationRepository->delete($emailVerification);
Auth::login($user);
return view('authentication::__front.verification.success');
}
示例5: index
public function index($projectId, Request $request)
{
$project = Project::findOrFail($projectId);
if ($request->ajax()) {
$query = $project->checklists();
if ($request->query('date')) {
$query->whereDate('created_at', '=', new Carbon($request->query('date')));
}
$checklists = $query->with('subcontractor')->get();
$checklists->map(function ($checklist) {
if ($checklist->checkitems()->whereNull('passes')->exists()) {
$checklist->passes = false;
} else {
$checklist->passes = true;
}
return $checklist;
});
return response()->json(compact('checklists'));
}
$checklists = $project->checklists->map(function ($checklist) {
if ($checklist->checkitems()->whereNull('passes')->exists()) {
$checklist->passes = false;
} else {
$checklist->passes = true;
}
if ($checklist->checkitems()->wherePasses(false)->exists()) {
$checklist->hasFailure = true;
} else {
$checklist->hasFailure = false;
}
return $checklist;
});
return view('project-checklists.index')->withProject($project)->withChecklists($checklists);
}
示例6: getSort
/**
* To sort item of page.
* @return View
*/
public function getSort(Request $request)
{
$this->repo->grabAllLists();
$model = $this->repo->makeQuery();
$sortable = true;
if ($this->repo->isSortFilterFormConfigExists()) {
$sortable = false;
if ($request->has('filter')) {
$sortable = true;
$filter = array_except($request->query(), $this->filterExcept);
foreach ($filter as $item) {
if (!$item) {
$sortable = false;
}
}
$model = $this->repo->filter($filter, $model);
}
view()->share('beforeSortShouldFilter', !$sortable);
view()->share('filterForm', Formaker::setModel($this->repo->getModel())->make($request->all()));
}
$limit = $request->input('perPage', $this->paginationCount);
$items = $this->repo->showByPage($limit, $request->query(), $model->with($this->relations));
$data = ['paginationCount' => $limit, 'sortable' => $sortable, 'rules' => $this->functionRules];
$lister = Lister::make($items, $this->listConfig, $data);
event('controllerAfterAction', ['']);
return $this->layout()->with('listEmpty', $items->isEmpty())->with('sortable', $sortable)->with('lister', $lister);
}
示例7: search
public function search(Request $request)
{
$searchTerm = $request->query('quick_s');
$searchType = $request->query('quick_t');
switch ($searchType) {
case 'a':
$asset = Asset::whereIdentifier($searchTerm)->first();
if (isset($asset->id)) {
return redirect('assets/' . $asset->id);
} else {
return redirect("assets?identifier={$searchTerm}");
}
break;
case 'j':
$job = Job::whereId($searchTerm)->first();
if (isset($job->id)) {
return redirect('jobs/' . $job->id);
} else {
return redirect("jobs?id={$searchTerm}");
}
break;
case 'jl':
$jobList = JobList::whereName($searchTerm)->first();
if (isset($jobList->id)) {
return redirect('job-lists/' . $jobList->id);
} else {
return redirect("job-lists?name={$searchTerm}");
}
break;
default:
$this->view->quick_t = $searchType;
$this->view->quick_s = $searchTerm;
return $this->view;
}
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$accessKey = env('ACCESS_KEY');
if (!$request->query('key') || $request->query('key') !== $accessKey) {
return response('Unauthorized.', 401);
}
return $next($request);
}
示例9: logout
/**
* This initiates a logout request across all the SSO infrastructure.
*/
public function logout(Request $request)
{
$returnTo = $request->query('returnTo');
$sessionIndex = $request->query('sessionIndex');
$nameId = $request->query('nameId');
$this->saml2Auth->logout($returnTo, $nameId, $sessionIndex);
//will actually end up in the sls endpoint
//does not return
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->query('tmpl')) {
$finder = app('themes.view.finder');
$basePath = config('themes.path.frontend', base_path('themes')) . DIRECTORY_SEPARATOR . $request->query('tmpl');
$finder->setBasePath($basePath);
}
return $next($request);
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
if ($request->query('list_id') !== NULL) {
$list = TodoList::find($request->query('list_id'));
$tasks = $list->tasks;
} else {
$tasks = Task::get();
}
return response()->json($tasks);
}
示例12: __construct
public function __construct(CategoryInterface $repo, Request $request)
{
$this->repo = $repo;
$this->categoryLayerNumber = config('module.category.layer');
if ($request->query('category')) {
session()->put('sharenjoy.categoryType', $request->query('category'));
}
$this->type = session('sharenjoy.categoryType');
parent::__construct();
view()->share('specifyName', pick_trans('menu.' . $this->type . '_category'));
}
示例13: getTokenForRequest
/**
* Get the token for the current request.
*
* @return string
*/
public function getTokenForRequest()
{
$token = $this->request->query($this->inputKey);
if (empty($token)) {
$token = $this->request->bearerToken();
}
if (empty($token)) {
$token = $this->request->getPassword();
}
return $token;
}
示例14: serve
public function serve(Request $request, $filename)
{
if (config('attach.sign')) {
$url = url($request->url(), array_except($request->query(), ['signature', 'expire']));
$signature = $request->query('signature', '');
$expiry = $request->query('expiry', 0);
if (!verify_url_signature($url, $signature, $expiry)) {
return abort(404);
}
}
return serve_attachment($filename);
}
示例15: index
public function index(Request $request)
{
$model = $this->model->find(auth()->user()->id);
${camel_case($this->base)} = $model;
$this->title = title_case(trans('livecms::livecms.' . $this->base));
$this->description = trans('livecms::livecms.homeprofile');
$this->breadcrumb3 = trans('livecms::livecms.myprofile');
$this->params = array_merge($request->query() ? $request->query() : []);
$this->action = 'store';
$this->view->share();
return view('livecms::user.profile.home', compact(camel_case($this->base)));
}