作者robinnpca (rob)
看板PHP
标题[请益] laravel request->all()
时间Sat Mar 17 12:05:26 2018
解决了但想请问为何?
用 $search_all['name'] 就可在view中读到
不过想请问的是
为何范例都是 request->all() 然後$search_all->name
为何网上的介绍是这样写的?
Retrieving Input Via Dynamic Properties
You may also access user input using dynamic properties on the
Illuminate\Http\Request instance. For example, if one of your application's
forms contains a name field, you may access the value of the field like so:
$name = $request->name;
When using dynamic properties, Laravel will first look for the parameter's
value in the request payload. If it is not present, Laravel will search for
the field in the route parameters.
-----------------------------------------------
由上页的form经由post指定到下面的 controller
public function index(Request $request)
{
$search_all= $request->all();
$search_name = $search_all->name; //error place
return $search_all.$search_name;
}
或我直接在view
<p>{{$search_all->name}}</p> 也会出现错误
Trying to get property of non-object
请问要怎样
将request->all()里面的数列取出呢?
我知道用request->input('name')可以
但是我不想要一个各取
想要一次在controller取全部
return view('pro.index')
->with('search',$searchall);
这样送去view然後
在view中 去一个个取出来
{{$search->name}}
不要在controller中取
看文章都是
轻易的在view
$search->name 就可以取到 先前送过来form里面的input select中的name
为何不成功呢?
请教怎麽处理?
解决了
用 $search_all['name'] 就可在view中读到
不过想请问的是
为何范例都是 request->all() 然後$search_all->name
为何网上的介绍是这样写的?
Retrieving Input Via Dynamic Properties
You may also access user input using dynamic properties on the
Illuminate\Http\Request instance. For example, if one of your application's
forms contains a name field, you may access the value of the field like so:
$name = $request->name;
When using dynamic properties, Laravel will first look for the parameter's
value in the request payload. If it is not present, Laravel will search for
the field in the route parameters.
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 122.116.4.129
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/PHP/M.1521259529.A.50A.html
※ 编辑: robinnpca (122.116.4.129), 03/17/2018 13:05:23
※ 编辑: robinnpca (122.116.4.129), 03/17/2018 13:05:47
※ 编辑: robinnpca (122.116.4.129), 03/17/2018 13:11:48
1F:推 y2468101216: 你去看request all回传的就知道了 03/17 13:54
2F:→ y2468101216: 他回传的是array而非obj 03/17 13:54