[英]Laravel 5.1 - How to access resource id in a Request authorize() method
我正在申请房地产。 当用户打开编辑表单以编辑其属性之一时,刀片代码将为:
{!!
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()
^ //add $id here
{
return Property::where('user_id', auth()->user()->id)
->where('id', <<< HERE IS WHERE I NEED THE ID FROM THE FORM >>)
->exists();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.