在Laravel 5.2中将页面URL参数传递给控制器 [英] Passing page URL parameter to controller in Laravel 5.2

查看:414
本文介绍了在Laravel 5.2中将页面URL参数传递给控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个名为index.blade的页面,其路由为/index.在其URL中,它具有一些get参数,例如?order?type.

In my application I have a page it called index.blade, with route /index. In its URL, it has some get parameter like ?order and ?type.

我想将这些$_get参数传递给我的路由控制器操作,从数据库中查询并将其结果数据传递给索引页面.我该怎么办?

I want to pass these $_get parameter to my route controller action, query from DB and pass its result data to the index page. What should I do?

推荐答案

如果要访问从getpost请求发送的数据,请使用

If you want to access the data sent from get or post request use

public function store(Request $request)
{
    $order = $request->input('order');
    $type = $request->input('type');
    return view('whatever')->with('order', $order)->with('type', $type);
}

您还可以使用通配符.

示例链接

website.dev/user/potato

路线

Route::put('user/{name}', 'UserController@show');

控制器

public function update( $name)
{
    User::where('name', $name)->first();
    return view('test')->with('user', $user);
}

检查Laravel文档 请求 .

Check the Laravel Docs Requests.

这篇关于在Laravel 5.2中将页面URL参数传递给控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆