Php 拉威尔5号:Can';使用带有模型绑定的get方法时,无法获取id
我需要在表单中使用GET来生成url查询字符串,但我还需要在路由中使用的模型id。基本上,我想用表单提交生成的url查询字符串扩展show($id)方法。但是它没有得到id(POST方法也没有得到id) 以下是我所拥有的: fund.blade.phpPhp 拉威尔5号:Can';使用带有模型绑定的get方法时,无法获取id,php,forms,laravel,routing,laravel-5,Php,Forms,Laravel,Routing,Laravel 5,我需要在表单中使用GET来生成url查询字符串,但我还需要在路由中使用的模型id。基本上,我想用表单提交生成的url查询字符串扩展show($id)方法。但是它没有得到id(POST方法也没有得到id) 以下是我所拥有的: fund.blade.php {!! Form::model($fund, ['route' => 'funds.getQuery', 'method' => 'get'], $fund->id) !!} {!! Form::select('from', $
{!! Form::model($fund, ['route' => 'funds.getQuery', 'method' => 'get'], $fund->id) !!}
{!! Form::select('from', $years) !!}
{!! Form::select('to', $years) !!}
{!! Form::submit('Submit') !!}
{!! Form::close() !!}
routes.php
Route::get('funds/test/{funds}', [ 'as' => 'funds.getQuery', function($id){
$to = Input::get('to');
$from = Input::get('from');
$donations = Donation::whereBetween('Date_Submitted_Adjusted', [
new Carbon($to),
new Carbon($from)
])
->orderBy('Date_Submitted_Adjusted', 'asc')
->get();
$urlString = url('funds', $parameters = [
'id' => $id,
'from' => $from,
'to' => $to
]);
return $urlString;
}]);
我的show/{id}方法工作正常。我做错了什么?在查看一些在线文档时,似乎应该随路由一起传递特定的对象id。与此相反: {!!Form::model($fund,['route'=>'funds.getQuery','method'=>'get'],$fund->id) 你能试试下面的吗 {!!Form::model($fund,['route'=>array('funds.getQuery',$fund->id),'method'=>'get'])