【发布时间】:2015-09-19 13:45:06
【问题描述】:
我正在申请房地产。当用户打开编辑表单来编辑他的一个属性时,刀片代码将是:
{!!
Form::model($property,
[
'method'=>'PATCH',
'route'=>'property.update',
$property->id
])
!!}
如您所见,当前正在编辑的属性的 ID 是最后一个数组元素。
如何在请求的 authorize() 函数中访问该 ID?
class EditPropertyRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Property::where('user_id', auth()->user()->id)
->where('id', <<< HERE IS WHERE I NEED THE ID FROM THE FORM >>)
->exists();
}
// ...
}
【问题讨论】:
-
public function authorize($id) -
我可以将此作为答案并接受吗? :D
-
哈哈,去吧,把答案放上去
-
啊哈哈。肿瘤坏死因子。您忘记将
$id放在那里。赶上你通过的id。 :D